mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Add deprecation warning for unmountComponentAtNode
This should have been deprecated in 18.0 alongside the other legacy DOM APIs like render().
This commit is contained in:
+12
@@ -393,7 +393,19 @@ export function unstable_renderSubtreeIntoContainer(
|
||||
);
|
||||
}
|
||||
|
||||
let didWarnAboutUnmountComponentAtNode = false;
|
||||
export function unmountComponentAtNode(container: Container) {
|
||||
if (__DEV__) {
|
||||
if (!didWarnAboutUnmountComponentAtNode) {
|
||||
didWarnAboutUnmountComponentAtNode = true;
|
||||
console.error(
|
||||
'unmountComponentAtNode is deprecated and will be removed in the ' +
|
||||
'next major release. Switch to the createRoot API. Learn ' +
|
||||
'more: https://reactjs.org/link/switch-to-createroot',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (!isValidContainerLegacy(container)) {
|
||||
throw new Error(
|
||||
'unmountComponentAtNode(...): Target container is not a DOM element.',
|
||||
|
||||
@@ -32,7 +32,9 @@ module.exports = function shouldIgnoreConsoleError(format, args) {
|
||||
) !== -1 ||
|
||||
format.indexOf('ReactDOMTestUtils is deprecated') !== -1 ||
|
||||
format.indexOf('`ReactDOMTestUtils.act` is deprecated') !== -1 ||
|
||||
format.indexOf('findDOMNode is deprecated and will be removed') !== -1
|
||||
format.indexOf('findDOMNode is deprecated and will be removed') !==
|
||||
-1 ||
|
||||
format.indexOf('unmountComponentAtNode is deprecated') !== -1
|
||||
) {
|
||||
// This is a backported warning. In `main`, there's a different warning
|
||||
// (and it's fully tested). Not going to bother upgrading all the tests
|
||||
|
||||
Reference in New Issue
Block a user