-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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 - today logs a bunch of warnings for ReactDom.render being deprecated #21946
Comments
I spend a lot of time on this. #22334 is pretty close. The problem is in React 18, you need to do import ReactDOM from 'react-dom/client'
ReactDOM.createRoot(...) In React 17 and below, this isn't an option. One idea I had was a dynamic import: if (isUsingReact18) {
return import('react-dom/client')
.then((mod) => {
const root = mod.default.createRoot(el)
root.render(reactComponent)
return wrapAndRender()
})
} else {
// React 17 path...
} This would be fine in regular ESM - but both Webpack and Vite do some optimizations and look through the code and find the conditional import, and error (even if the path isn't actually executed). This is very annoying. I wrote a Vite plugin to ignore this import if the React version is 17... Works great! I cannot figure out how to do the same for Webpack, though. The error doesn't actually block development, it's just a big ugly. We could proxy This is the only blocker on React 18. |
Current Behavior
Thought we had an issue for React-18 support but couldn't find one.
ReactDOM.render
is deprecated and logs a bunch of warnings┆Issue is synchronized with this Jira Bug by Unito
┆Attachments: Screen Shot 2022-04-21 at 12.43.59 PM.png
┆author: Zach Williams
┆epic: CT Architecture
┆friendlyId: UNIFY-1639
┆priority: Medium
┆sprint: Backlog
┆taskType: Bug
The text was updated successfully, but these errors were encountered: