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

Support for React 18 #57

Closed
edward-simpson opened this issue Aug 17, 2022 · 8 comments
Closed

Support for React 18 #57

edward-simpson opened this issue Aug 17, 2022 · 8 comments

Comments

@edward-simpson
Copy link

Because this plugin uses reactDom.render in it's gatsby-browser.js, it prevents using react 18 features:

Warning: ReactDOM.render is no longer supported in React 18. Use createRoot instead. Until you switch to the new API, your app will behave as if it's running React 17. Learn more: https://reactjs.org/link/switch-to-createroot
@lezan
Copy link

lezan commented Aug 28, 2022

I am experience the same warning. I tried to check all the libraries used and this one appears to have to do with it.

@graysonhicks
Copy link
Owner

Thanks both! I'll look at the best way to switch the render method. One option is releasing a new major version of this plugin to align with Gatsby v5, which will have React 18 as a requirement.

@graysonhicks graysonhicks mentioned this issue Sep 16, 2022
@graysonhicks
Copy link
Owner

I am afraid this is an upstream problem with loadable: gregberge/loadable-components#718

I recommend migrating to React.lazy for code-splitting + SSR with React 18.

@graysonhicks
Copy link
Owner

I have removed the React 18 allowance from peer deps in 4.3.0 until this is resolved, but I am not really motivated to push React 18 support for this plugin, when React will now have an official solution baked in.

@lezan
Copy link

lezan commented Oct 2, 2022

@graysonhicks I did the migration to React.lazy and Suspense, but I am not able to run it (getting this one gatsbyjs/gatsby#36678). Not sure it is a solution supported by Gatbsy.

@graysonhicks
Copy link
Owner

Thanks @lezan but it is supported by Gatsby (despite the apparent bug).

@lezan
Copy link

lezan commented Oct 4, 2022

Hey @graysonhicks sorry to bother. Does it means is not a bug but I am doing something wrong?

@graysonhicks
Copy link
Owner

No worries @lezan it may be a bug, or it may be user error. I've responded to your issue on the Gatsby repo and we can track there. Regardless, this plugin will not support React 18, as Gatsby v5 will with React.lazy.

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

No branches or pull requests

3 participants