Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

React 18 support #148

Merged
merged 19 commits into from
Aug 25, 2022
Merged

React 18 support #148

merged 19 commits into from
Aug 25, 2022

Conversation

filoxo
Copy link
Contributor

@filoxo filoxo commented Jul 26, 2022

Resolves #142 and #115.


// required - one or the other
rootComponent: null,
loadRootComponent: null,

// optional opts
renderType: null,
renderType: "createRoot",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be considered a breaking change?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, yeah, probably, since it changes a lot of how React itself renders things.

export interface SingleSpaReactOpts<RootComponentProps> {
React: typeof React;
ReactDOM: typeof ReactDOM;
React: any;
Copy link

@dgreene1 dgreene1 Aug 11, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whenever possible, we should avoid the any type. I'm not sure what was wrong with the previously used type typeof React since React is a peer dependency. If I'm understanding peer dependencies correctly (and I'm not really sure if I am), the type of that import would be defined by the version of React that the user has.

And the same point for the other props.

So I would expect the types to be:

import * as ReactDOM from "react-dom";
import * as ReactDOMClient from "react-dom/client";
//...
export interface SingleSpaReactOpts<RootComponentProps> {
  React: typeof React;
  ReactDOM?: typeof ReactDOM;
  ReactDOMClient?: typeof ReactDOMClient;
  //...
}

Maybe the source of the problem in @hijiangtao's comment #142 (comment) is that react-dom is not a peer dependency? Can it be @filoxo? Or maybe the source of the issue is just that my grasp on types from peer-dependencies is just off. Could be! In which case, forgive me for this PR comment of mine.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dgreene1 right, please also see #144 (review) and #144 (comment). if I'm using React 17 still and my version of react types doesn't have ReactDOMClient, wouldn't this completely break? The whole point is that we want backwards compatibility so using ReactDOMClient type is not possible without making single-spa-react incompatible with react 17 and below. At least that's my understanding.

@filoxo filoxo merged commit c2cf485 into main Aug 25, 2022
@filoxo filoxo deleted the feat/react-18-support-minor-version branch August 25, 2022 02:38
@eolamisan
Copy link

eolamisan commented Jul 13, 2023

Has React 18 support made it to npm?

version 5.1.1 still has the old code in minified version.

image

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Getting warning from ReactDOM when using React 18
4 participants