-
Notifications
You must be signed in to change notification settings - Fork 47.2k
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
Deprecate ReactDOM.render and ReactDOM.hydrate #21652
Conversation
We have a warning filter for our internal tests to ignore warnings that are too noisy or that we haven't removed from our test suite yet: shouldIgnoreConsoleError. Many of our server rendering tests don't use this filter, though, because it has its own special of asserting warnings. So I added the warning filter to the server tests, too.
These are no longer supported in React 18. They are replaced by the `createRoot` API. The warning includes a link to documentation of the new API. Currently it redirects to the corresponding working group post. Here's the PR to set up the redirect: reactjs/react.dev#3730 Many of our tests still use ReactDOM.render. We will need to gradually migrate them over to createRoot. In the meantime, I added the warnings to our internal warning filter.
@@ -10,6 +10,7 @@ | |||
'use strict'; | |||
|
|||
const stream = require('stream'); | |||
const shouldIgnoreConsoleError = require('../../../../../scripts/jest/shouldIgnoreConsoleError'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gross but oh well
6d8823d
to
b5d54fa
Compare
Comparing: 1a3f1af...0cc374a Critical size changesIncludes critical production bundles, as well as any change greater than 2%:
Significant size changesIncludes any change greater than 0.2%: (No significant changes) |
b5d54fa
to
0cc374a
Compare
@@ -250,6 +259,15 @@ export function render( | |||
container: Container, | |||
callback: ?Function, | |||
) { | |||
if (__DEV__) { | |||
console.error( | |||
'ReactDOM.render is no longer supported in React 18. Use createRoot ' + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe use "ReactDOM.render is deprecated in React 18" instead for consistent messaging? "not supported" sounds like it's no longer working. Unless the other deprecation warnings also use "not supported" instead of "deprecated".
* Use existing test warning filter for server tests We have a warning filter for our internal tests to ignore warnings that are too noisy or that we haven't removed from our test suite yet: shouldIgnoreConsoleError. Many of our server rendering tests don't use this filter, though, because it has its own special of asserting warnings. So I added the warning filter to the server tests, too. * Deprecate ReactDOM.render and ReactDOM.hydrate These are no longer supported in React 18. They are replaced by the `createRoot` API. The warning includes a link to documentation of the new API. Currently it redirects to the corresponding working group post. Here's the PR to set up the redirect: reactjs/react.dev#3730 Many of our tests still use ReactDOM.render. We will need to gradually migrate them over to createRoot. In the meantime, I added the warnings to our internal warning filter.
@@ -219,6 +219,15 @@ export function hydrate( | |||
container: Container, | |||
callback: ?Function, | |||
) { | |||
if (__DEV__) { | |||
console.error( | |||
'ReactDOM.hydrate is no longer supported in React 18. Use createRoot ' + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it weird that we say "no longer supported in React 18" as if it was ever supported in React 18?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ReactDOM.hydrate is deprecated in React 18.
These are no longer supported in React 18. They are replaced by the
createRoot
API.The warning includes a link to documentation of the new API. Currently it redirects to the corresponding working group post:
https://reactjs.org/link/switch-to-createroot
Many of our tests still use ReactDOM.render. We will need to gradually migrate them over to createRoot.
In the meantime, I added the warnings to our internal warning filter.