From e09673d25195d8244ccc3d26d91020984c592d8f Mon Sep 17 00:00:00 2001 From: Jack Pope Date: Tue, 23 Jul 2024 15:39:20 -0400 Subject: [PATCH] Remove allowConcurrentByDefault flag --- .../src/__tests__/ReactDOMRoot-test.js | 35 ------------------- packages/react-dom/src/client/ReactDOMRoot.js | 23 ++---------- packages/react-reconciler/src/ReactFiber.js | 10 ------ .../react-reconciler/src/ReactFiberLane.js | 16 +-------- .../src/ReactFiberReconciler.js | 4 +-- .../react-reconciler/src/ReactFiberRoot.js | 7 +--- .../react-reconciler/src/ReactTypeOfMode.js | 1 - .../src/ReactTestRenderer.js | 11 +----- .../ReactTestRenderer-test.internal.js | 2 +- packages/shared/ReactFeatureFlags.js | 3 -- .../forks/ReactFeatureFlags.native-fb.js | 1 - .../forks/ReactFeatureFlags.native-oss.js | 1 - .../forks/ReactFeatureFlags.test-renderer.js | 1 - ...actFeatureFlags.test-renderer.native-fb.js | 1 - .../ReactFeatureFlags.test-renderer.www.js | 1 - .../shared/forks/ReactFeatureFlags.www.js | 2 -- 16 files changed, 9 insertions(+), 110 deletions(-) diff --git a/packages/react-dom/src/__tests__/ReactDOMRoot-test.js b/packages/react-dom/src/__tests__/ReactDOMRoot-test.js index 5ab8e4e90294d..355ad8cc28311 100644 --- a/packages/react-dom/src/__tests__/ReactDOMRoot-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMRoot-test.js @@ -17,7 +17,6 @@ let Scheduler = require('scheduler'); let act; let useEffect; let assertLog; -let waitFor; let waitForAll; describe('ReactDOMRoot', () => { @@ -36,7 +35,6 @@ describe('ReactDOMRoot', () => { const InternalTestUtils = require('internal-test-utils'); assertLog = InternalTestUtils.assertLog; - waitFor = InternalTestUtils.waitFor; waitForAll = InternalTestUtils.waitForAll; }); @@ -306,39 +304,6 @@ describe('ReactDOMRoot', () => { }).rejects.toThrow('The node to be removed is not a child of this node.'); }); - it('opts-in to concurrent default updates', async () => { - const root = ReactDOMClient.createRoot(container, { - unstable_concurrentUpdatesByDefault: true, - }); - - function Foo({value}) { - Scheduler.log(value); - return
{value}
; - } - - await act(() => { - root.render(); - }); - - assertLog(['a']); - expect(container.textContent).toEqual('a'); - - await act(async () => { - root.render(); - - assertLog([]); - expect(container.textContent).toEqual('a'); - - await waitFor(['b']); - if (gate(flags => flags.allowConcurrentByDefault)) { - expect(container.textContent).toEqual('a'); - } else { - expect(container.textContent).toEqual('b'); - } - }); - expect(container.textContent).toEqual('b'); - }); - it('unmount is synchronous', async () => { const root = ReactDOMClient.createRoot(container); await act(() => { diff --git a/packages/react-dom/src/client/ReactDOMRoot.js b/packages/react-dom/src/client/ReactDOMRoot.js index aef8775de5a16..98ec6f9236fed 100644 --- a/packages/react-dom/src/client/ReactDOMRoot.js +++ b/packages/react-dom/src/client/ReactDOMRoot.js @@ -16,10 +16,7 @@ import type { import {isValidContainer} from 'react-dom-bindings/src/client/ReactDOMContainer'; import {queueExplicitHydrationTarget} from 'react-dom-bindings/src/events/ReactDOMEventReplaying'; import {REACT_ELEMENT_TYPE} from 'shared/ReactSymbols'; -import { - allowConcurrentByDefault, - enableAsyncActions, -} from 'shared/ReactFeatureFlags'; +import {enableAsyncActions} from 'shared/ReactFeatureFlags'; export type RootType = { render(children: ReactNodeList): void, @@ -29,7 +26,6 @@ export type RootType = { export type CreateRootOptions = { unstable_strictMode?: boolean, - unstable_concurrentUpdatesByDefault?: boolean, unstable_transitionCallbacks?: TransitionTracingCallbacks, identifierPrefix?: string, onUncaughtError?: ( @@ -55,7 +51,6 @@ export type HydrateRootOptions = { onDeleted?: (suspenseNode: Comment) => void, // Options for all roots unstable_strictMode?: boolean, - unstable_concurrentUpdatesByDefault?: boolean, unstable_transitionCallbacks?: TransitionTracingCallbacks, identifierPrefix?: string, onUncaughtError?: ( @@ -173,8 +168,8 @@ export function createRoot( warnIfReactDOMContainerInDEV(container); + const concurrentUpdatesByDefaultOverride = false; let isStrictMode = false; - let concurrentUpdatesByDefaultOverride = false; let identifierPrefix = ''; let onUncaughtError = defaultOnUncaughtError; let onCaughtError = defaultOnCaughtError; @@ -206,12 +201,6 @@ export function createRoot( if (options.unstable_strictMode === true) { isStrictMode = true; } - if ( - allowConcurrentByDefault && - options.unstable_concurrentUpdatesByDefault === true - ) { - concurrentUpdatesByDefaultOverride = true; - } if (options.identifierPrefix !== undefined) { identifierPrefix = options.identifierPrefix; } @@ -289,8 +278,8 @@ export function hydrateRoot( // the hydration callbacks. const hydrationCallbacks = options != null ? options : null; + const concurrentUpdatesByDefaultOverride = false; let isStrictMode = false; - let concurrentUpdatesByDefaultOverride = false; let identifierPrefix = ''; let onUncaughtError = defaultOnUncaughtError; let onCaughtError = defaultOnCaughtError; @@ -301,12 +290,6 @@ export function hydrateRoot( if (options.unstable_strictMode === true) { isStrictMode = true; } - if ( - allowConcurrentByDefault && - options.unstable_concurrentUpdatesByDefault === true - ) { - concurrentUpdatesByDefaultOverride = true; - } if (options.identifierPrefix !== undefined) { identifierPrefix = options.identifierPrefix; } diff --git a/packages/react-reconciler/src/ReactFiber.js b/packages/react-reconciler/src/ReactFiber.js index 7db42bc9ce67a..db9c4773444e1 100644 --- a/packages/react-reconciler/src/ReactFiber.js +++ b/packages/react-reconciler/src/ReactFiber.js @@ -31,7 +31,6 @@ import { enableProfilerTimer, enableScopeAPI, enableLegacyHidden, - allowConcurrentByDefault, enableTransitionTracing, enableDebugTracing, enableDO_NOT_USE_disableStrictPassiveEffect, @@ -85,7 +84,6 @@ import { ProfileMode, StrictLegacyMode, StrictEffectsMode, - ConcurrentUpdatesByDefaultMode, NoStrictPassiveEffectsMode, } from './ReactTypeOfMode'; import { @@ -524,7 +522,6 @@ export function resetWorkInProgress( export function createHostRootFiber( tag: RootTag, isStrictMode: boolean, - concurrentUpdatesByDefaultOverride: null | boolean, ): Fiber { let mode; if (disableLegacyMode || tag === ConcurrentRoot) { @@ -532,13 +529,6 @@ export function createHostRootFiber( if (isStrictMode === true) { mode |= StrictLegacyMode | StrictEffectsMode; } - if ( - // Only for internal experiments. - allowConcurrentByDefault && - concurrentUpdatesByDefaultOverride - ) { - mode |= ConcurrentUpdatesByDefaultMode; - } } else { mode = NoMode; } diff --git a/packages/react-reconciler/src/ReactFiberLane.js b/packages/react-reconciler/src/ReactFiberLane.js index 7b81c406cf5e8..f34f1aeccd85a 100644 --- a/packages/react-reconciler/src/ReactFiberLane.js +++ b/packages/react-reconciler/src/ReactFiberLane.js @@ -19,7 +19,6 @@ export type Lane = number; export type LaneMap = Array; import { - allowConcurrentByDefault, enableRetryLaneExpiration, enableSchedulingProfiler, enableTransitionTracing, @@ -29,7 +28,6 @@ import { retryLaneExpirationMs, } from 'shared/ReactFeatureFlags'; import {isDevToolsPresent} from './ReactFiberDevToolsHook'; -import {ConcurrentUpdatesByDefaultMode, NoMode} from './ReactTypeOfMode'; import {clz32} from './clz32'; // Lane values below should be kept in sync with getLabelForLane(), used by react-devtools-timeline. @@ -287,12 +285,7 @@ export function getNextLanes(root: FiberRoot, wipLanes: Lanes): Lanes { export function getEntangledLanes(root: FiberRoot, renderLanes: Lanes): Lanes { let entangledLanes = renderLanes; - if ( - allowConcurrentByDefault && - (root.current.mode & ConcurrentUpdatesByDefaultMode) !== NoMode - ) { - // Do nothing, use the lanes as they were assigned. - } else if ((entangledLanes & InputContinuousLane) !== NoLanes) { + if ((entangledLanes & InputContinuousLane) !== NoLanes) { // When updates are sync by default, we entangle continuous priority updates // and default updates, so they render in the same batch. The only reason // they use separate lanes is because continuous updates should interrupt @@ -498,13 +491,6 @@ export function includesOnlyTransitions(lanes: Lanes): boolean { } export function includesBlockingLane(root: FiberRoot, lanes: Lanes): boolean { - if ( - allowConcurrentByDefault && - (root.current.mode & ConcurrentUpdatesByDefaultMode) !== NoMode - ) { - // Concurrent updates by default always use time slicing. - return false; - } const SyncDefaultLanes = InputContinuousHydrationLane | InputContinuousLane | diff --git a/packages/react-reconciler/src/ReactFiberReconciler.js b/packages/react-reconciler/src/ReactFiberReconciler.js index 4d793f9c60876..fa6052e0efcac 100644 --- a/packages/react-reconciler/src/ReactFiberReconciler.js +++ b/packages/react-reconciler/src/ReactFiberReconciler.js @@ -238,6 +238,7 @@ export function createContainer( tag: RootTag, hydrationCallbacks: null | SuspenseHydrationCallbacks, isStrictMode: boolean, + // TODO: Remove `concurrentUpdatesByDefaultOverride`. It is now ignored. concurrentUpdatesByDefaultOverride: null | boolean, identifierPrefix: string, onUncaughtError: ( @@ -266,7 +267,6 @@ export function createContainer( initialChildren, hydrationCallbacks, isStrictMode, - concurrentUpdatesByDefaultOverride, identifierPrefix, onUncaughtError, onCaughtError, @@ -284,6 +284,7 @@ export function createHydrationContainer( tag: RootTag, hydrationCallbacks: null | SuspenseHydrationCallbacks, isStrictMode: boolean, + // TODO: Remove `concurrentUpdatesByDefaultOverride`. It is now ignored. concurrentUpdatesByDefaultOverride: null | boolean, identifierPrefix: string, onUncaughtError: ( @@ -312,7 +313,6 @@ export function createHydrationContainer( initialChildren, hydrationCallbacks, isStrictMode, - concurrentUpdatesByDefaultOverride, identifierPrefix, onUncaughtError, onCaughtError, diff --git a/packages/react-reconciler/src/ReactFiberRoot.js b/packages/react-reconciler/src/ReactFiberRoot.js index e69989e61624d..27590743ad79f 100644 --- a/packages/react-reconciler/src/ReactFiberRoot.js +++ b/packages/react-reconciler/src/ReactFiberRoot.js @@ -147,7 +147,6 @@ export function createFiberRoot( initialChildren: ReactNodeList, hydrationCallbacks: null | SuspenseHydrationCallbacks, isStrictMode: boolean, - concurrentUpdatesByDefaultOverride: null | boolean, // TODO: We have several of these arguments that are conceptually part of the // host config, but because they are passed in at runtime, we have to thread // them through the root constructor. Perhaps we should put them all into a @@ -192,11 +191,7 @@ export function createFiberRoot( // Cyclic construction. This cheats the type system right now because // stateNode is any. - const uninitializedFiber = createHostRootFiber( - tag, - isStrictMode, - concurrentUpdatesByDefaultOverride, - ); + const uninitializedFiber = createHostRootFiber(tag, isStrictMode); root.current = uninitializedFiber; uninitializedFiber.stateNode = root; diff --git a/packages/react-reconciler/src/ReactTypeOfMode.js b/packages/react-reconciler/src/ReactTypeOfMode.js index 6da450ffeac6d..7542c8eff528c 100644 --- a/packages/react-reconciler/src/ReactTypeOfMode.js +++ b/packages/react-reconciler/src/ReactTypeOfMode.js @@ -16,5 +16,4 @@ export const ProfileMode = /* */ 0b0000010; export const DebugTracingMode = /* */ 0b0000100; export const StrictLegacyMode = /* */ 0b0001000; export const StrictEffectsMode = /* */ 0b0010000; -export const ConcurrentUpdatesByDefaultMode = /* */ 0b0100000; export const NoStrictPassiveEffectsMode = /* */ 0b1000000; diff --git a/packages/react-test-renderer/src/ReactTestRenderer.js b/packages/react-test-renderer/src/ReactTestRenderer.js index a9d251b795e6e..5b0e854e0488c 100644 --- a/packages/react-test-renderer/src/ReactTestRenderer.js +++ b/packages/react-test-renderer/src/ReactTestRenderer.js @@ -56,7 +56,6 @@ import {checkPropStringCoercion} from 'shared/CheckStringCoercion'; import {getPublicInstance} from './ReactFiberConfigTestHost'; import {ConcurrentRoot, LegacyRoot} from 'react-reconciler/src/ReactRootTags'; import { - allowConcurrentByDefault, enableReactTestRendererWarning, disableLegacyMode, } from 'shared/ReactFeatureFlags'; @@ -70,7 +69,6 @@ type TestRendererOptions = { createNodeMock: (element: React$Element) => any, unstable_isConcurrent: boolean, unstable_strictMode: boolean, - unstable_concurrentUpdatesByDefault: boolean, ... }; @@ -486,7 +484,6 @@ function create( global.IS_REACT_NATIVE_TEST_ENVIRONMENT !== true; let isConcurrent = isConcurrentOnly; let isStrictMode = false; - let concurrentUpdatesByDefault = null; if (typeof options === 'object' && options !== null) { if (typeof options.createNodeMock === 'function') { // $FlowFixMe[incompatible-type] found when upgrading Flow @@ -498,12 +495,6 @@ function create( if (options.unstable_strictMode === true) { isStrictMode = true; } - if (allowConcurrentByDefault) { - if (options.unstable_concurrentUpdatesByDefault !== undefined) { - concurrentUpdatesByDefault = - options.unstable_concurrentUpdatesByDefault; - } - } } let container = { children: ([]: Array), @@ -515,7 +506,7 @@ function create( isConcurrent ? ConcurrentRoot : LegacyRoot, null, isStrictMode, - concurrentUpdatesByDefault, + false, '', defaultOnUncaughtError, defaultOnCaughtError, diff --git a/packages/react-test-renderer/src/__tests__/ReactTestRenderer-test.internal.js b/packages/react-test-renderer/src/__tests__/ReactTestRenderer-test.internal.js index 4364d48f031c7..f596183589705 100644 --- a/packages/react-test-renderer/src/__tests__/ReactTestRenderer-test.internal.js +++ b/packages/react-test-renderer/src/__tests__/ReactTestRenderer-test.internal.js @@ -93,7 +93,7 @@ describe('ReactTestRenderer', () => { tag, null, expect.anything(), - null, + false, expect.anything(), expect.anything(), expect.anything(), diff --git a/packages/shared/ReactFeatureFlags.js b/packages/shared/ReactFeatureFlags.js index 2e3ffd81191c8..6d400f7deee08 100644 --- a/packages/shared/ReactFeatureFlags.js +++ b/packages/shared/ReactFeatureFlags.js @@ -217,9 +217,6 @@ export const enableUseDeferredValueInitialArg = true; // when we plan to enable them. // ----------------------------------------------------------------------------- -// Adds an opt-in to time slicing for updates that aren't wrapped in startTransition. -export const allowConcurrentByDefault = false; - // ----------------------------------------------------------------------------- // React DOM Chopping Block // diff --git a/packages/shared/forks/ReactFeatureFlags.native-fb.js b/packages/shared/forks/ReactFeatureFlags.native-fb.js index 0e00c97a1aae8..961eeac850fc3 100644 --- a/packages/shared/forks/ReactFeatureFlags.native-fb.js +++ b/packages/shared/forks/ReactFeatureFlags.native-fb.js @@ -27,7 +27,6 @@ export const { } = dynamicFlags; // The rest of the flags are static for better dead code elimination. -export const allowConcurrentByDefault = false; export const consoleManagedByDevToolsDuringStrictMode = true; export const debugRenderPhaseSideEffectsForStrictMode = __DEV__; export const disableClientCache = true; diff --git a/packages/shared/forks/ReactFeatureFlags.native-oss.js b/packages/shared/forks/ReactFeatureFlags.native-oss.js index ce2bc8251cb1a..3cf7347c96bdb 100644 --- a/packages/shared/forks/ReactFeatureFlags.native-oss.js +++ b/packages/shared/forks/ReactFeatureFlags.native-oss.js @@ -19,7 +19,6 @@ export const debugRenderPhaseSideEffectsForStrictMode = __DEV__; // ----------------------------------------------------------------------------- // All other flags // ----------------------------------------------------------------------------- -export const allowConcurrentByDefault = false; export const alwaysThrottleRetries = false; export const consoleManagedByDevToolsDuringStrictMode = true; export const disableClientCache = true; diff --git a/packages/shared/forks/ReactFeatureFlags.test-renderer.js b/packages/shared/forks/ReactFeatureFlags.test-renderer.js index 310a64ba778e7..5857ecde9b594 100644 --- a/packages/shared/forks/ReactFeatureFlags.test-renderer.js +++ b/packages/shared/forks/ReactFeatureFlags.test-renderer.js @@ -53,7 +53,6 @@ export const transitionLaneExpirationMs = 5000; export const disableSchedulerTimeoutInWorkLoop = false; export const enableLazyContextPropagation = false; export const enableLegacyHidden = false; -export const allowConcurrentByDefault = false; export const consoleManagedByDevToolsDuringStrictMode = false; diff --git a/packages/shared/forks/ReactFeatureFlags.test-renderer.native-fb.js b/packages/shared/forks/ReactFeatureFlags.test-renderer.native-fb.js index 4b3ceb37bdf48..866ee338ca514 100644 --- a/packages/shared/forks/ReactFeatureFlags.test-renderer.native-fb.js +++ b/packages/shared/forks/ReactFeatureFlags.test-renderer.native-fb.js @@ -10,7 +10,6 @@ import typeof * as FeatureFlagsType from 'shared/ReactFeatureFlags'; import typeof * as ExportsType from './ReactFeatureFlags.test-renderer'; -export const allowConcurrentByDefault = true; export const alwaysThrottleRetries = false; export const consoleManagedByDevToolsDuringStrictMode = false; export const debugRenderPhaseSideEffectsForStrictMode = false; diff --git a/packages/shared/forks/ReactFeatureFlags.test-renderer.www.js b/packages/shared/forks/ReactFeatureFlags.test-renderer.www.js index 8c487e27c8239..ed426c39641b4 100644 --- a/packages/shared/forks/ReactFeatureFlags.test-renderer.www.js +++ b/packages/shared/forks/ReactFeatureFlags.test-renderer.www.js @@ -56,7 +56,6 @@ export const transitionLaneExpirationMs = 5000; export const disableSchedulerTimeoutInWorkLoop = false; export const enableLazyContextPropagation = false; export const enableLegacyHidden = false; -export const allowConcurrentByDefault = true; export const consoleManagedByDevToolsDuringStrictMode = false; diff --git a/packages/shared/forks/ReactFeatureFlags.www.js b/packages/shared/forks/ReactFeatureFlags.www.js index 02726ce6b24c5..860769c3b95e7 100644 --- a/packages/shared/forks/ReactFeatureFlags.www.js +++ b/packages/shared/forks/ReactFeatureFlags.www.js @@ -96,8 +96,6 @@ export const enableRefAsProp = true; export const disableTextareaChildren = __EXPERIMENTAL__; -export const allowConcurrentByDefault = true; - export const consoleManagedByDevToolsDuringStrictMode = true; export const enableFizzExternalRuntime = true;