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:
Andrew Clark
2024-04-25 12:22:01 -04:00
parent c3b2839641
commit 8a015b68cc
2 changed files with 15 additions and 1 deletions
+12
View File
@@ -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.',
+3 -1
View File
@@ -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