forked from facebook/react
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deprecate ReactDOM.render and ReactDOM.hydrate (facebook#21652)
* 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.
- Loading branch information
Showing
10 changed files
with
146 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
packages/react-dom/src/__tests__/ReactLegacyRootWarnings-test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
let ReactDOM = require('react-dom'); | ||
|
||
describe('ReactDOMRoot', () => { | ||
let container; | ||
|
||
beforeEach(() => { | ||
jest.resetModules(); | ||
container = document.createElement('div'); | ||
ReactDOM = require('react-dom'); | ||
}); | ||
|
||
test('deprecation warning for ReactDOM.render', () => { | ||
spyOnDev(console, 'error'); | ||
|
||
ReactDOM.render('Hi', container); | ||
expect(container.textContent).toEqual('Hi'); | ||
if (__DEV__) { | ||
expect(console.error).toHaveBeenCalledTimes(1); | ||
expect(console.error.calls.argsFor(0)[0]).toContain( | ||
'ReactDOM.render is no longer supported', | ||
); | ||
} | ||
}); | ||
|
||
test('deprecation warning for ReactDOM.hydrate', () => { | ||
spyOnDev(console, 'error'); | ||
|
||
container.innerHTML = 'Hi'; | ||
ReactDOM.hydrate('Hi', container); | ||
expect(container.textContent).toEqual('Hi'); | ||
if (__DEV__) { | ||
expect(console.error).toHaveBeenCalledTimes(1); | ||
expect(console.error.calls.argsFor(0)[0]).toContain( | ||
'ReactDOM.hydrate is no longer supported', | ||
); | ||
} | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters