Browser console warning about React 18 and ReactDOM.render
See original GitHub issueDescribe the bug
Now that React 18 is released, creating a new project (npx create-react-app my-project
) and running that project will show the browser console warning:
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
printWarning @ react-dom.development.js:86
The project DOES run, however.
Did you try recovering your dependencies?
N/A as a new project
npm --version is: 8.1.4
Which terms did you search for in User Guide?
Didn’t find anything for “React 18” or “render” or “ReactDOM”
Environment
Environment Info:
current version of create-react-app: 5.0.0
running from /Users/swiftone/.npm/_npx/c67e74de0542c87c/node_modules/create-react-app
System:
OS: macOS 12.1
CPU: (8) x64 Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz
Binaries:
Node: 16.13.0 - ~/.nvm/versions/node/v16.13.0/bin/node
Yarn: Not Found
npm: 8.1.4 - ~/.nvm/versions/node/v16.13.0/bin/npm
Browsers:
Chrome: 99.0.4844.84
Edge: Not Found
Firefox: 94.0.1
Safari: 15.2
npmPackages:
react: ^18.0.0 => 18.0.0
react-dom: ^18.0.0 => 18.0.0
react-scripts: 5.0.0 => 5.0.0
npmGlobalPackages:
create-react-app: Not Found
Steps to reproduce
npx create-react-app my-project
cd my-project
npm start
- (view console in browser)
Expected behavior
No browser console errors
Actual behavior
Reproducible demo
Any project, see steps to reproduce
Issue Analytics
- State:
- Created a year ago
- Reactions:12
- Comments:10 (1 by maintainers)
Top Results From Across the Web
React js Warning: ReactDOM.render is no longer supported in ...
ReactDOM.render is no longer supported in React 18-Solution That's it now the warning is gone. so finally Browser console is look like:.
Read more >ReactDOM.render is no longer supported in React 18 - Stack ...
React 18 shipped March 29th, 2022. ReactDOM.render has been deprecated in React 18 and currently issues a warning and runs in a compatible ......
Read more >How to fix ReactDOM.render is no longer supported in React 18
Tutorial on how to fix the error ReactDOM.render is no longer supported in React 18 when you upgrade react version.
Read more >How to fix recent warning “ReactDOM.render is no longer ...
Warning message on browser console: “Warning: ReactDOM.render is no longer supported in React 18. Use createRoot instead.
Read more >Warning: ReactDOM.render is no longer supported in React 18
... is no longer supported in React 18 | ReactJS errorYou can find the code here :https://bluewonk.blogspot.com/2022/07/ warning - reactdom...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
While this should be a pretty trivial fix to the template, I must admit I was a bit surprised CRA just installed a different major version of React - wouldn’t it make sense to have a setting for the major version or React it assumes?
Working example in TypeScript with react-router v6: