Skip to content

Commit

Permalink
Add a flag to disable legacy ReactDOM APIs and set it for modern builds
Browse files Browse the repository at this point in the history
  • Loading branch information
gaearon committed Feb 10, 2020
1 parent c3d4f6a commit 4c8e018
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 6 deletions.
14 changes: 8 additions & 6 deletions packages/react-dom/src/client/ReactDOM.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ import ReactVersion from 'shared/ReactVersion';
import invariant from 'shared/invariant';
import {
exposeConcurrentModeAPIs,
disableLegacyReactDOMAPIs,
disableUnstableCreatePortal,
disableUnstableRenderSubtreeIntoContainer,
warnUnstableRenderSubtreeIntoContainer,
Expand Down Expand Up @@ -134,12 +135,6 @@ function createPortal(
const ReactDOM: Object = {
createPortal,

// Legacy
findDOMNode,
hydrate,
render,
unmountComponentAtNode,

unstable_batchedUpdates: batchedUpdates,

flushSync: flushSync,
Expand Down Expand Up @@ -167,6 +162,13 @@ const ReactDOM: Object = {
version: ReactVersion,
};

if (!disableLegacyReactDOMAPIs) {
ReactDOM.findDOMNode = findDOMNode;
ReactDOM.hydrate = hydrate;
ReactDOM.render = render;
ReactDOM.unmountComponentAtNode = unmountComponentAtNode;
}

if (exposeConcurrentModeAPIs) {
ReactDOM.createRoot = createRoot;
ReactDOM.createBlockingRoot = createBlockingRoot;
Expand Down
2 changes: 2 additions & 0 deletions packages/shared/ReactFeatureFlags.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ export const disableLegacyContext = false;
// Disables React.createFactory
export const disableCreateFactory = false;

export const disableLegacyReactDOMAPIs = false;

// Disables children for <textarea> elements
export const disableTextareaChildren = false;

Expand Down
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 @@ -46,6 +46,7 @@ export const disableSchedulerTimeoutBasedOnReactExpirationTime = false;
export const enableTrainModelFix = true;
export const enableTrustedTypesIntegration = false;
export const disableCreateFactory = false;
export const disableLegacyReactDOMAPIs = false;
export const disableTextareaChildren = false;
export const disableMapsAsChildren = false;
export const disableUnstableRenderSubtreeIntoContainer = false;
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 @@ -41,6 +41,7 @@ export const enableTrainModelFix = true;
export const enableTrustedTypesIntegration = false;
export const enableNativeTargetAsInstance = false;
export const disableCreateFactory = false;
export const disableLegacyReactDOMAPIs = false;
export const disableTextareaChildren = false;
export const disableMapsAsChildren = false;
export const disableUnstableRenderSubtreeIntoContainer = false;
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 @@ -41,6 +41,7 @@ export const enableTrainModelFix = true;
export const enableTrustedTypesIntegration = false;
export const enableNativeTargetAsInstance = false;
export const disableCreateFactory = false;
export const disableLegacyReactDOMAPIs = false;
export const disableTextareaChildren = false;
export const disableMapsAsChildren = false;
export const disableUnstableRenderSubtreeIntoContainer = false;
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 @@ -41,6 +41,7 @@ export const enableTrainModelFix = true;
export const enableTrustedTypesIntegration = false;
export const enableNativeTargetAsInstance = false;
export const disableCreateFactory = false;
export const disableLegacyReactDOMAPIs = false;
export const disableTextareaChildren = false;
export const disableMapsAsChildren = false;
export const disableUnstableRenderSubtreeIntoContainer = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export const enableTrainModelFix = true;
export const enableTrustedTypesIntegration = false;
export const enableNativeTargetAsInstance = false;
export const disableCreateFactory = false;
export const disableLegacyReactDOMAPIs = false;
export const disableTextareaChildren = false;
export const disableMapsAsChildren = false;
export const disableUnstableRenderSubtreeIntoContainer = false;
Expand Down
1 change: 1 addition & 0 deletions packages/shared/forks/ReactFeatureFlags.testing.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export const enableTrainModelFix = true;
export const enableTrustedTypesIntegration = false;
export const enableNativeTargetAsInstance = false;
export const disableCreateFactory = false;
export const disableLegacyReactDOMAPIs = false;
export const disableTextareaChildren = false;
export const disableMapsAsChildren = false;
export const disableUnstableRenderSubtreeIntoContainer = false;
Expand Down
2 changes: 2 additions & 0 deletions packages/shared/forks/ReactFeatureFlags.www-classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ export const enableNativeTargetAsInstance = false;

export const disableCreateFactory = false;

export const disableLegacyReactDOMAPIs = false;

export const disableTextareaChildren = false;

export const disableMapsAsChildren = false;
Expand Down
2 changes: 2 additions & 0 deletions packages/shared/forks/ReactFeatureFlags.www-modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ export const enableNativeTargetAsInstance = false;

export const disableCreateFactory = false;

export const disableLegacyReactDOMAPIs = true;

export const disableTextareaChildren = true;

export const disableMapsAsChildren = true;
Expand Down

0 comments on commit 4c8e018

Please sign in to comment.