Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable classic features in the modern WWW build #18013

Closed
wants to merge 8 commits into from
17 changes: 11 additions & 6 deletions packages/react-dom/src/client/ReactDOM.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import {
attemptHydrationAtCurrentPriority,
act,
} from 'react-reconciler/inline.dom';
import {getIsHydrating} from 'react-reconciler/src/ReactFiberHydrationContext';
import {createPortal as createPortalImpl} from 'shared/ReactPortal';
import {canUseDOM} from 'shared/ExecutionEnvironment';
import {setBatchingImplementation} from 'legacy-events/ReactGenericBatching';
Expand All @@ -56,6 +57,7 @@ import ReactVersion from 'shared/ReactVersion';
import invariant from 'shared/invariant';
import {
exposeConcurrentModeAPIs,
disableLegacyReactDOMAPIs,
disableUnstableCreatePortal,
disableUnstableRenderSubtreeIntoContainer,
warnUnstableRenderSubtreeIntoContainer,
Expand Down Expand Up @@ -133,12 +135,6 @@ function createPortal(
const ReactDOM: Object = {
createPortal,

// Legacy
findDOMNode,
hydrate,
render,
unmountComponentAtNode,

unstable_batchedUpdates: batchedUpdates,

flushSync: flushSync,
Expand Down Expand Up @@ -166,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 All @@ -179,6 +182,8 @@ if (exposeConcurrentModeAPIs) {
queueExplicitHydrationTarget(target);
}
};

ReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.getIsHydrating = getIsHydrating;
}

if (!disableUnstableRenderSubtreeIntoContainer) {
Expand Down
3 changes: 0 additions & 3 deletions packages/react-dom/src/client/ReactDOMFB.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
* @flow
*/

import {getIsHydrating} from 'react-reconciler/src/ReactFiberHydrationContext';
import {addUserTimingListener} from 'shared/ReactFeatureFlags';

import ReactDOM from './ReactDOM';
Expand All @@ -26,8 +25,6 @@ Object.assign(
},
// Perf experiment
addUserTimingListener,

getIsHydrating,
},
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
const EventListenerWWW = require('EventListener');

import typeof * as EventListenerType from '../EventListener';
import typeof * as EventListenerShimType from './EventListener-www';
import typeof * as EventListenerShimType from './EventListener.www-classic';

export function addEventBubbleListener(
element: Element,
Expand Down
8 changes: 6 additions & 2 deletions packages/react-reconciler/src/ReactFiber.js
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,9 @@ export function createWorkInProgress(

if (__DEV__) {
// DEV-only fields
workInProgress._debugID = current._debugID;
if (enableUserTimingAPI) {
workInProgress._debugID = current._debugID;
}
workInProgress._debugSource = current._debugSource;
workInProgress._debugOwner = current._debugOwner;
workInProgress._debugHookTypes = current._debugHookTypes;
Expand Down Expand Up @@ -958,7 +960,9 @@ export function assignFiberPropertiesInDEV(
target.selfBaseDuration = source.selfBaseDuration;
target.treeBaseDuration = source.treeBaseDuration;
}
target._debugID = source._debugID;
if (enableUserTimingAPI) {
target._debugID = source._debugID;
}
target._debugSource = source._debugSource;
target._debugOwner = source._debugOwner;
target._debugIsCurrentlyTiming = source._debugIsCurrentlyTiming;
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
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/

import typeof * as FeatureFlagsType from 'shared/ReactFeatureFlags';
import typeof * as FeatureFlagsShimType from './ReactFeatureFlags.www';
import typeof * as FeatureFlagsShimType from './ReactFeatureFlags.www-classic';

// Re-export dynamic flags from the www version.
export const {
Expand Down 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
86 changes: 86 additions & 0 deletions packages/shared/forks/ReactFeatureFlags.www-modern.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/

import typeof * as FeatureFlagsType from 'shared/ReactFeatureFlags';
import typeof * as FeatureFlagsShimType from './ReactFeatureFlags.www-modern';

// Re-export dynamic flags from the www version.
export const {
debugRenderPhaseSideEffectsForStrictMode,
disableInputAttributeSyncing,
enableTrustedTypesIntegration,
deferPassiveEffectCleanupDuringUnmount,
warnAboutShorthandPropertyCollision,
} = require('ReactFeatureFlags');

export let enableUserTimingAPI = false;

export const enableProfilerTimer = __PROFILE__;
export const enableSchedulerTracing = __PROFILE__;
export const enableSchedulerDebugging = true;

export const replayFailedUnitOfWorkWithInvokeGuardedCallback = false;
export const warnAboutDeprecatedLifecycles = true;
export const disableLegacyContext = true;
export const warnAboutStringRefs = false;
export const warnAboutDefaultPropsOnFunctionComponents = false;
export const disableSchedulerTimeoutBasedOnReactExpirationTime = false;

export const enableTrainModelFix = true;

export const exposeConcurrentModeAPIs = __EXPERIMENTAL__;

export const enableSuspenseServerRenderer = true;
export const enableSelectiveHydration = true;

export const enableChunksAPI = __EXPERIMENTAL__;

export const disableJavaScriptURLs = true;

export function addUserTimingListener() {
throw new Error('Not implemented.');
}

export const enableDeprecatedFlareAPI = true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a comment to group the two sets up more? I’m worried people will add to the bottom of this list and it will get muddled up otherwise.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is 100% copy paste from the other file. I agree we should clean it up but let's do this separately from this PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good.


export const enableFundamentalAPI = false;

export const enableScopeAPI = true;

export const enableJSXTransformAPI = true;

export const warnAboutUnmockedScheduler = true;

export const enableSuspenseCallback = true;

export const flushSuspenseFallbacksInTests = true;

export const enableNativeTargetAsInstance = false;

export const disableCreateFactory = false;

export const disableLegacyReactDOMAPIs = true;

export const disableTextareaChildren = true;

export const disableMapsAsChildren = true;

export const disableUnstableRenderSubtreeIntoContainer = true;

export const warnUnstableRenderSubtreeIntoContainer = false;

export const disableUnstableCreatePortal = true;

export const isTestEnvironment = false;

// Flow magic to verify the exports of this file match the original version.
// eslint-disable-next-line no-unused-vars
type Check<_X, Y: _X, X: Y = _X> = null;
// eslint-disable-next-line no-unused-expressions
(null: Check<FeatureFlagsShimType, FeatureFlagsType>);
Loading