Skip to content

Commit

Permalink
Add ReactDOM.unstable_renderSubtreeIntoContainer warning flag (#17936)
Browse files Browse the repository at this point in the history
  • Loading branch information
trueadm authored Jan 30, 2020
1 parent 01974a8 commit b2382a7
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,18 @@ if (ReactFeatureFlags.disableUnstableRenderSubtreeIntoContainer) {
}

componentDidMount() {
expect(
function() {
renderSubtreeIntoContainer(this, <Component />, portal);
}.bind(this),
).toWarnDev(
'ReactDOM.unstable_renderSubtreeIntoContainer() is deprecated and ' +
'will be removed in a future major release. Consider using React Portals instead.',
);
if (ReactFeatureFlags.warnUnstableRenderSubtreeIntoContainer) {
expect(
function() {
renderSubtreeIntoContainer(this, <Component />, portal);
}.bind(this),
).toWarnDev(
'ReactDOM.unstable_renderSubtreeIntoContainer() is deprecated and ' +
'will be removed in a future major release. Consider using React Portals instead.',
);
} else {
renderSubtreeIntoContainer(this, <Component />, portal);
}
}
}

Expand Down
6 changes: 5 additions & 1 deletion packages/react-dom/src/client/ReactDOM.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ import {
exposeConcurrentModeAPIs,
disableUnstableCreatePortal,
disableUnstableRenderSubtreeIntoContainer,
warnUnstableRenderSubtreeIntoContainer,
} from 'shared/ReactFeatureFlags';

import {
Expand Down Expand Up @@ -179,7 +180,10 @@ if (exposeConcurrentModeAPIs) {
if (!disableUnstableRenderSubtreeIntoContainer) {
ReactDOM.unstable_renderSubtreeIntoContainer = function(...args) {
if (__DEV__) {
if (!didWarnAboutUnstableRenderSubtreeIntoContainer) {
if (
warnUnstableRenderSubtreeIntoContainer &&
!didWarnAboutUnstableRenderSubtreeIntoContainer
) {
didWarnAboutUnstableRenderSubtreeIntoContainer = true;
console.warn(
'ReactDOM.unstable_renderSubtreeIntoContainer() is deprecated ' +
Expand Down
2 changes: 2 additions & 0 deletions packages/shared/ReactFeatureFlags.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ export const disableTextareaChildren = false;

// Disables ReactDOM.unstable_renderSubtreeIntoContainer
export const disableUnstableRenderSubtreeIntoContainer = false;
// We should remove this flag once the above flag becomes enabled
export const warnUnstableRenderSubtreeIntoContainer = false;

// Disables ReactDOM.unstable_createPortal
export const disableUnstableCreatePortal = false;
1 change: 1 addition & 0 deletions packages/shared/forks/ReactFeatureFlags.native-fb.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export const enableTrustedTypesIntegration = false;
export const disableCreateFactory = false;
export const disableTextareaChildren = false;
export const disableUnstableRenderSubtreeIntoContainer = false;
export const warnUnstableRenderSubtreeIntoContainer = false;
export const disableUnstableCreatePortal = false;

// Only used in www builds.
Expand Down
1 change: 1 addition & 0 deletions packages/shared/forks/ReactFeatureFlags.native-oss.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export const enableNativeTargetAsInstance = false;
export const disableCreateFactory = false;
export const disableTextareaChildren = false;
export const disableUnstableRenderSubtreeIntoContainer = false;
export const warnUnstableRenderSubtreeIntoContainer = false;
export const disableUnstableCreatePortal = false;

// Only used in www builds.
Expand Down
1 change: 1 addition & 0 deletions packages/shared/forks/ReactFeatureFlags.persistent.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export const enableNativeTargetAsInstance = false;
export const disableCreateFactory = false;
export const disableTextareaChildren = false;
export const disableUnstableRenderSubtreeIntoContainer = false;
export const warnUnstableRenderSubtreeIntoContainer = false;
export const disableUnstableCreatePortal = false;

// Only used in www builds.
Expand Down
1 change: 1 addition & 0 deletions packages/shared/forks/ReactFeatureFlags.test-renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export const enableNativeTargetAsInstance = false;
export const disableCreateFactory = false;
export const disableTextareaChildren = false;
export const disableUnstableRenderSubtreeIntoContainer = false;
export const warnUnstableRenderSubtreeIntoContainer = false;
export const disableUnstableCreatePortal = false;

// Only used in www builds.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export const enableNativeTargetAsInstance = false;
export const disableCreateFactory = false;
export const disableTextareaChildren = false;
export const disableUnstableRenderSubtreeIntoContainer = false;
export const warnUnstableRenderSubtreeIntoContainer = false;
export const disableUnstableCreatePortal = false;

// Only used in www builds.
Expand Down
2 changes: 2 additions & 0 deletions packages/shared/forks/ReactFeatureFlags.www.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ export const disableTextareaChildren = false;

export const disableUnstableRenderSubtreeIntoContainer = false;

export const warnUnstableRenderSubtreeIntoContainer = false;

export const disableUnstableCreatePortal = false;

// Flow magic to verify the exports of this file match the original version.
Expand Down

0 comments on commit b2382a7

Please sign in to comment.