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

Fresh apps are created with React/ReactDom ^18 but boilerplate still uses ReactDom.render instead of the new createRoot #12244

Closed
KenAKAFrosty opened this issue Apr 4, 2022 · 2 comments

Comments

@KenAKAFrosty
Copy link

Describe the bug

Warning is printed to console:

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

While this itself is not breaking, it does provide a very jarring developer experience to have that kind of error out of the box. This could be particularly confusing or worrisome to new developers or developers new to React.

Did you try recovering your dependencies?

I manually reverted back to 17.0.2 for both React and ReactDom

Which terms did you search for in User Guide?

This seems entirely related to the new React 18 that was just released a few days ago, so there wasn't any relevant information in the docs/user guide. I did see a few other related issues like #12239, stemming from the same issue of using React 18 but not fully preparing CRA to handle it. It seems this could signal more upcoming issues in the near future if CRA continues to use React 18.

Environment

current version of create-react-app: 5.0.0

System:
OS: Windows 10 10.0.19043
CPU: (16) x64 11th Gen Intel(R) Core(TM) i7-11800H @ 2.30GHz
Binaries:
Node: 16.14.2 - C:\Program Files\nodejs\node.EXE
Yarn: Not Found
npm: 8.5.0 - C:\Program Files\nodejs\npm.CMD
Browsers:
Chrome: Not Found
Edge: Spartan (44.19041.1266.0), Chromium (99.0.1150.55)
Internet Explorer: 11.0.19041.1566
npmPackages:
react: ^17.0.2 => 17.0.2
react-dom: ^17.0.2 => 17.0.2
react-scripts: 5.0.0 => 5.0.0

( Again please note that I've since reverted to react/dom to 17.0.2, but when the CRA was fresh installed it was ^18 )

Steps to reproduce

(Write your steps here:)

  1. Start a simple boilerplate fresh app with npx create-react-app app-name
  2. Fire up the app with npm start
  3. Look at console and see warning

Expected behavior

I'd expect either the default boilerplate to use the new createRoot + root.render approach, or for CRA to default to the previous version of React.

Actual behavior

Received this warning in the console.

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

@kyletsang
Copy link
Contributor

Duplicate of #12219 and this will be fixed in #12220

@KenAKAFrosty
Copy link
Author

Awesome thanks

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

No branches or pull requests

2 participants