Skip to content

Commit 8a015b6

Browse files
committed
Add deprecation warning for unmountComponentAtNode
This should have been deprecated in 18.0 alongside the other legacy DOM APIs like render().
1 parent c3b2839 commit 8a015b6

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

packages/react-dom/src/client/ReactDOMLegacy.js

+12
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,19 @@ export function unstable_renderSubtreeIntoContainer(
393393
);
394394
}
395395

396+
let didWarnAboutUnmountComponentAtNode = false;
396397
export function unmountComponentAtNode(container: Container) {
398+
if (__DEV__) {
399+
if (!didWarnAboutUnmountComponentAtNode) {
400+
didWarnAboutUnmountComponentAtNode = true;
401+
console.error(
402+
'unmountComponentAtNode is deprecated and will be removed in the ' +
403+
'next major release. Switch to the createRoot API. Learn ' +
404+
'more: https://reactjs.org/link/switch-to-createroot',
405+
);
406+
}
407+
}
408+
397409
if (!isValidContainerLegacy(container)) {
398410
throw new Error(
399411
'unmountComponentAtNode(...): Target container is not a DOM element.',

scripts/jest/shouldIgnoreConsoleError.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ module.exports = function shouldIgnoreConsoleError(format, args) {
3232
) !== -1 ||
3333
format.indexOf('ReactDOMTestUtils is deprecated') !== -1 ||
3434
format.indexOf('`ReactDOMTestUtils.act` is deprecated') !== -1 ||
35-
format.indexOf('findDOMNode is deprecated and will be removed') !== -1
35+
format.indexOf('findDOMNode is deprecated and will be removed') !==
36+
-1 ||
37+
format.indexOf('unmountComponentAtNode is deprecated') !== -1
3638
) {
3739
// This is a backported warning. In `main`, there's a different warning
3840
// (and it's fully tested). Not going to bother upgrading all the tests

0 commit comments

Comments
 (0)