diff --git a/packages/react-art/src/__tests__/ReactART-test.js b/packages/react-art/src/__tests__/ReactART-test.js index 6cc38b47b8d7a..714e19d1cc1fe 100644 --- a/packages/react-art/src/__tests__/ReactART-test.js +++ b/packages/react-art/src/__tests__/ReactART-test.js @@ -33,8 +33,6 @@ const ReactTestRenderer = require('react-test-renderer'); // Isolate the noop renderer jest.resetModules(); -const ReactNoop = require('react-noop-renderer'); -const Scheduler = require('scheduler'); let Group; let Shape; @@ -359,58 +357,6 @@ describe('ReactART', () => { doClick(instance); expect(onClick2).toBeCalled(); }); - - // @gate !enableSyncDefaultUpdates - it('can concurrently render with a "primary" renderer while sharing context', () => { - const CurrentRendererContext = React.createContext(null); - - function Yield(props) { - Scheduler.unstable_yieldValue(props.value); - return null; - } - - let ops = []; - function LogCurrentRenderer() { - return ( - - {currentRenderer => { - ops.push(currentRenderer); - return null; - }} - - ); - } - - // Using test renderer instead of the DOM renderer here because async - // testing APIs for the DOM renderer don't exist. - ReactNoop.render( - - - - - - , - ); - - expect(Scheduler).toFlushAndYieldThrough(['A']); - - ReactDOM.render( - - - - - - , - container, - ); - - expect(ops).toEqual([null, 'ART']); - - ops = []; - expect(Scheduler).toFlushAndYield(['B', 'C']); - - expect(ops).toEqual(['Test']); - }); }); describe('ReactARTComponents', () => { diff --git a/packages/react-dom/src/__tests__/ReactDOMNativeEventHeuristic-test.js b/packages/react-dom/src/__tests__/ReactDOMNativeEventHeuristic-test.js index 15605af8702d5..cfdeecf718f03 100644 --- a/packages/react-dom/src/__tests__/ReactDOMNativeEventHeuristic-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMNativeEventHeuristic-test.js @@ -305,11 +305,7 @@ describe('ReactDOMNativeEventHeuristic-test', () => { expect(container.textContent).toEqual('not hovered'); expect(Scheduler).toFlushAndYieldThrough(['hovered']); - if (gate(flags => flags.enableSyncDefaultUpdates)) { - expect(container.textContent).toEqual('hovered'); - } else { - expect(container.textContent).toEqual('not hovered'); - } + expect(container.textContent).toEqual('hovered'); }); expect(container.textContent).toEqual('hovered'); }); diff --git a/packages/react-dom/src/__tests__/ReactDOMServerPartialHydration-test.internal.js b/packages/react-dom/src/__tests__/ReactDOMServerPartialHydration-test.internal.js index 3886cfe7f3201..0862865f76004 100644 --- a/packages/react-dom/src/__tests__/ReactDOMServerPartialHydration-test.internal.js +++ b/packages/react-dom/src/__tests__/ReactDOMServerPartialHydration-test.internal.js @@ -2044,14 +2044,7 @@ describe('ReactDOMServerPartialHydration', () => { suspend = true; await act(async () => { - if (gate(flags => flags.enableSyncDefaultUpdates)) { - expect(Scheduler).toFlushAndYieldThrough(['Before', 'After']); - } else { - expect(Scheduler).toFlushAndYieldThrough(['Before']); - // This took a long time to render. - Scheduler.unstable_advanceTime(1000); - expect(Scheduler).toFlushAndYield(['After']); - } + expect(Scheduler).toFlushAndYieldThrough(['Before', 'After']); // This will cause us to skip the second row completely. }); diff --git a/packages/react-dom/src/events/__tests__/DOMPluginEventSystem-test.internal.js b/packages/react-dom/src/events/__tests__/DOMPluginEventSystem-test.internal.js index 3cad26f326e1b..6202eec7f3574 100644 --- a/packages/react-dom/src/events/__tests__/DOMPluginEventSystem-test.internal.js +++ b/packages/react-dom/src/events/__tests__/DOMPluginEventSystem-test.internal.js @@ -1965,13 +1965,9 @@ describe('DOMPluginEventSystem', () => { log.length = 0; // Increase counter - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - root.render(); - }); - } else { + React.startTransition(() => { root.render(); - } + }); // Yield before committing expect(Scheduler).toFlushAndYieldThrough(['Test']); diff --git a/packages/react-reconciler/src/ReactFiber.js b/packages/react-reconciler/src/ReactFiber.js index b5c89a56df292..e3fc26659c45c 100644 --- a/packages/react-reconciler/src/ReactFiber.js +++ b/packages/react-reconciler/src/ReactFiber.js @@ -33,7 +33,6 @@ import { enableProfilerTimer, enableScopeAPI, enableLegacyHidden, - enableSyncDefaultUpdates, allowConcurrentByDefault, enableTransitionTracing, enableDebugTracing, @@ -459,11 +458,9 @@ export function createHostRootFiber( mode |= StrictLegacyMode | StrictEffectsMode; } if ( - // We only use this flag for our repo tests to check both behaviors. - // TODO: Flip this flag and rename it something like "forceConcurrentByDefaultForTesting" - !enableSyncDefaultUpdates || // Only for internal experiments. - (allowConcurrentByDefault && concurrentUpdatesByDefaultOverride) + allowConcurrentByDefault && + concurrentUpdatesByDefaultOverride ) { mode |= ConcurrentUpdatesByDefaultMode; } diff --git a/packages/react-reconciler/src/__tests__/ReactDisableSchedulerTimeoutBasedOnReactExpirationTime-test.internal.js b/packages/react-reconciler/src/__tests__/ReactDisableSchedulerTimeoutBasedOnReactExpirationTime-test.internal.js index 00608912346c4..2d6828eca1dba 100644 --- a/packages/react-reconciler/src/__tests__/ReactDisableSchedulerTimeoutBasedOnReactExpirationTime-test.internal.js +++ b/packages/react-reconciler/src/__tests__/ReactDisableSchedulerTimeoutBasedOnReactExpirationTime-test.internal.js @@ -63,13 +63,9 @@ describe('ReactSuspenseList', () => { root.render(); expect(Scheduler).toFlushAndYield([]); - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - root.render(); - }); - } else { + React.startTransition(() => { root.render(); - } + }); expect(Scheduler).toFlushAndYield([ 'Suspend! [A]', 'Suspend! [B]', diff --git a/packages/react-reconciler/src/__tests__/ReactExpiration-test.js b/packages/react-reconciler/src/__tests__/ReactExpiration-test.js index 7b96efc2b9f9e..fb041f948f15d 100644 --- a/packages/react-reconciler/src/__tests__/ReactExpiration-test.js +++ b/packages/react-reconciler/src/__tests__/ReactExpiration-test.js @@ -115,13 +115,9 @@ describe('ReactExpiration', () => { } it('increases priority of updates as time progresses', () => { - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactNoop.render(); - }); - } else { + React.startTransition(() => { ReactNoop.render(); - } + }); expect(ReactNoop).toMatchRenderedOutput(null); @@ -162,13 +158,9 @@ describe('ReactExpiration', () => { // First, show what happens for updates in two separate events. // Schedule an update. - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactNoop.render(); - }); - } else { + React.startTransition(() => { ReactNoop.render(); - } + }); // Advance the timer. Scheduler.unstable_advanceTime(2000); // Partially flush the first update, then interrupt it. @@ -223,13 +215,9 @@ describe('ReactExpiration', () => { // First, show what happens for updates in two separate events. // Schedule an update. - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactNoop.render(); - }); - } else { + React.startTransition(() => { ReactNoop.render(); - } + }); // Advance the timer. Scheduler.unstable_advanceTime(2000); // Partially flush the first update, then interrupt it. @@ -301,13 +289,9 @@ describe('ReactExpiration', () => { } // Initial mount - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactNoop.render(); - }); - } else { + React.startTransition(() => { ReactNoop.render(); - } + }); expect(Scheduler).toFlushAndYield([ 'initial [A] [render]', 'initial [B] [render]', @@ -320,13 +304,9 @@ describe('ReactExpiration', () => { ]); // Partial update - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - subscribers.forEach(s => s.setState({text: '1'})); - }); - } else { + React.startTransition(() => { subscribers.forEach(s => s.setState({text: '1'})); - } + }); expect(Scheduler).toFlushAndYieldThrough([ '1 [A] [render]', '1 [B] [render]', @@ -358,13 +338,9 @@ describe('ReactExpiration', () => { ); } - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - root.render(); - }); - } else { + React.startTransition(() => { root.render(); - } + }); expect(Scheduler).toFlushAndYieldThrough(['A']); expect(Scheduler).toFlushAndYieldThrough(['B']); @@ -392,13 +368,9 @@ describe('ReactExpiration', () => { ); } - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - root.render(); - }); - } else { + React.startTransition(() => { root.render(); - } + }); expect(Scheduler).toFlushAndYieldThrough(['A']); expect(Scheduler).toFlushAndYieldThrough(['B']); @@ -426,13 +398,9 @@ describe('ReactExpiration', () => { // current time. ReactNoop = require('react-noop-renderer'); - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactNoop.render('Hi'); - }); - } else { + React.startTransition(() => { ReactNoop.render('Hi'); - } + }); // The update should not have expired yet. flushNextRenderIfExpired(); @@ -455,13 +423,9 @@ describe('ReactExpiration', () => { // Before scheduling an update, advance the current time. Scheduler.unstable_advanceTime(10000); - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactNoop.render('Hi'); - }); - } else { + React.startTransition(() => { ReactNoop.render('Hi'); - } + }); flushNextRenderIfExpired(); expect(Scheduler).toHaveYielded([]); expect(ReactNoop).toMatchRenderedOutput(null); @@ -504,13 +468,9 @@ describe('ReactExpiration', () => { // First demonstrate what happens when there's no starvation await act(async () => { - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - updateNormalPri(); - }); - } else { + React.startTransition(() => { updateNormalPri(); - } + }); expect(Scheduler).toFlushAndYieldThrough(['Sync pri: 0']); updateSyncPri(); expect(Scheduler).toHaveYielded(['Sync pri: 1', 'Normal pri: 0']); @@ -528,13 +488,9 @@ describe('ReactExpiration', () => { // Do the same thing, but starve the first update await act(async () => { - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - updateNormalPri(); - }); - } else { + React.startTransition(() => { updateNormalPri(); - } + }); expect(Scheduler).toFlushAndYieldThrough(['Sync pri: 1']); // This time, a lot of time has elapsed since the normal pri update @@ -690,13 +646,9 @@ describe('ReactExpiration', () => { expect(root).toMatchRenderedOutput('A0BC'); await act(async () => { - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - root.render(); - }); - } else { + React.startTransition(() => { root.render(); - } + }); expect(Scheduler).toFlushAndYield([ 'Suspend! [A1]', 'B', diff --git a/packages/react-reconciler/src/__tests__/ReactFlushSync-test.js b/packages/react-reconciler/src/__tests__/ReactFlushSync-test.js index 5802253e1c1f1..2ec6aa4889420 100644 --- a/packages/react-reconciler/src/__tests__/ReactFlushSync-test.js +++ b/packages/react-reconciler/src/__tests__/ReactFlushSync-test.js @@ -41,13 +41,9 @@ describe('ReactFlushSync', () => { const root = ReactNoop.createRoot(); await act(async () => { - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - root.render(); - }); - } else { + React.startTransition(() => { root.render(); - } + }); // This will yield right before the passive effect fires expect(Scheduler).toFlushUntilNextPaint(['0, 0']); diff --git a/packages/react-reconciler/src/__tests__/ReactHooksWithNoopRenderer-test.js b/packages/react-reconciler/src/__tests__/ReactHooksWithNoopRenderer-test.js index 2455f51965c21..6bfd7ae16fed2 100644 --- a/packages/react-reconciler/src/__tests__/ReactHooksWithNoopRenderer-test.js +++ b/packages/react-reconciler/src/__tests__/ReactHooksWithNoopRenderer-test.js @@ -167,15 +167,10 @@ describe('ReactHooksWithNoopRenderer', () => { // Schedule some updates act(() => { - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - counter.current.updateCount(1); - counter.current.updateCount(count => count + 10); - }); - } else { + React.startTransition(() => { counter.current.updateCount(1); counter.current.updateCount(count => count + 10); - } + }); // Partially flush without committing expect(Scheduler).toFlushAndYieldThrough(['Count: 11']); @@ -694,24 +689,16 @@ describe('ReactHooksWithNoopRenderer', () => { expect(Scheduler).toFlushAndYield([0]); expect(root).toMatchRenderedOutput(); - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - root.render(); - }); - } else { + React.startTransition(() => { root.render(); - } + }); expect(Scheduler).toFlushAndYield(['Suspend!']); expect(root).toMatchRenderedOutput(); // Rendering again should suspend again. - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - root.render(); - }); - } else { + React.startTransition(() => { root.render(); - } + }); expect(Scheduler).toFlushAndYield(['Suspend!']); }); @@ -757,38 +744,25 @@ describe('ReactHooksWithNoopRenderer', () => { expect(root).toMatchRenderedOutput(); await act(async () => { - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - root.render(); - setLabel('B'); - }); - } else { + React.startTransition(() => { root.render(); setLabel('B'); - } + }); expect(Scheduler).toFlushAndYield(['Suspend!']); expect(root).toMatchRenderedOutput(); // Rendering again should suspend again. - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - root.render(); - }); - } else { + React.startTransition(() => { root.render(); - } + }); expect(Scheduler).toFlushAndYield(['Suspend!']); // Flip the signal back to "cancel" the update. However, the update to // label should still proceed. It shouldn't have been dropped. - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - root.render(); - }); - } else { + React.startTransition(() => { root.render(); - } + }); expect(Scheduler).toFlushAndYield(['B:0']); expect(root).toMatchRenderedOutput(); }); @@ -823,13 +797,9 @@ describe('ReactHooksWithNoopRenderer', () => { ReactNoop.discreteUpdates(() => { setRow(5); }); - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - setRow(20); - }); - } else { + React.startTransition(() => { setRow(20); - } + }); }); expect(Scheduler).toHaveYielded(['Up', 'Down']); expect(root).toMatchRenderedOutput(); @@ -1362,13 +1332,9 @@ describe('ReactHooksWithNoopRenderer', () => { ]); // Schedule another update for children, and partially process it. - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - setChildStates.forEach(setChildState => setChildState(2)); - }); - } else { + React.startTransition(() => { setChildStates.forEach(setChildState => setChildState(2)); - } + }); expect(Scheduler).toFlushAndYieldThrough(['Child one render']); // Schedule unmount for the parent that unmounts children with pending update. @@ -1674,42 +1640,24 @@ describe('ReactHooksWithNoopRenderer', () => { expect(ReactNoop).toMatchRenderedOutput(); // Rendering again should flush the previous commit's effects - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactNoop.render(, () => - Scheduler.unstable_yieldValue('Sync effect'), - ); - }); - } else { + React.startTransition(() => { ReactNoop.render(, () => Scheduler.unstable_yieldValue('Sync effect'), ); - } + }); expect(Scheduler).toFlushAndYieldThrough([ 'Schedule update [0]', 'Count: 0', ]); - if (gate(flags => flags.enableSyncDefaultUpdates)) { - expect(ReactNoop).toMatchRenderedOutput(); - expect(Scheduler).toFlushAndYieldThrough([ - 'Count: 0', - 'Sync effect', - 'Schedule update [1]', - 'Count: 1', - ]); - } else { - expect(ReactNoop).toMatchRenderedOutput( - , - ); - expect(Scheduler).toFlushAndYieldThrough(['Sync effect']); - expect(ReactNoop).toMatchRenderedOutput(); - - ReactNoop.flushPassiveEffects(); - expect(Scheduler).toHaveYielded(['Schedule update [1]']); - expect(Scheduler).toFlushAndYield(['Count: 1']); - } + expect(ReactNoop).toMatchRenderedOutput(); + expect(Scheduler).toFlushAndYieldThrough([ + 'Count: 0', + 'Sync effect', + 'Schedule update [1]', + 'Count: 1', + ]); expect(ReactNoop).toMatchRenderedOutput(); }); diff --git a/packages/react-reconciler/src/__tests__/ReactIncremental-test.js b/packages/react-reconciler/src/__tests__/ReactIncremental-test.js index 47323ffc09f4f..21edc33da1711 100644 --- a/packages/react-reconciler/src/__tests__/ReactIncremental-test.js +++ b/packages/react-reconciler/src/__tests__/ReactIncremental-test.js @@ -65,17 +65,11 @@ describe('ReactIncremental', () => { return [, ]; } - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactNoop.render(, () => - Scheduler.unstable_yieldValue('callback'), - ); - }); - } else { + React.startTransition(() => { ReactNoop.render(, () => Scheduler.unstable_yieldValue('callback'), ); - } + }); // Do one step of work. expect(ReactNoop.flushNextYield()).toEqual(['Foo']); @@ -162,26 +156,18 @@ describe('ReactIncremental', () => { ReactNoop.render(); expect(Scheduler).toFlushAndYield(['Foo', 'Bar', 'Bar']); - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactNoop.render(); - }); - } else { + React.startTransition(() => { ReactNoop.render(); - } + }); // Flush part of the work expect(Scheduler).toFlushAndYieldThrough(['Foo', 'Bar']); // This will abort the previous work and restart ReactNoop.flushSync(() => ReactNoop.render(null)); - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactNoop.render(); - }); - } else { + React.startTransition(() => { ReactNoop.render(); - } + }); // Flush part of the new work expect(Scheduler).toFlushAndYieldThrough(['Foo', 'Bar']); @@ -215,17 +201,7 @@ describe('ReactIncremental', () => { ReactNoop.render(); expect(Scheduler).toFlushWithoutYielding(); - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - inst.setState( - () => { - Scheduler.unstable_yieldValue('setState1'); - return {text: 'bar'}; - }, - () => Scheduler.unstable_yieldValue('callback1'), - ); - }); - } else { + React.startTransition(() => { inst.setState( () => { Scheduler.unstable_yieldValue('setState1'); @@ -233,24 +209,14 @@ describe('ReactIncremental', () => { }, () => Scheduler.unstable_yieldValue('callback1'), ); - } + }); // Flush part of the work expect(Scheduler).toFlushAndYieldThrough(['setState1']); // This will abort the previous work and restart ReactNoop.flushSync(() => ReactNoop.render()); - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - inst.setState( - () => { - Scheduler.unstable_yieldValue('setState2'); - return {text2: 'baz'}; - }, - () => Scheduler.unstable_yieldValue('callback2'), - ); - }); - } else { + React.startTransition(() => { inst.setState( () => { Scheduler.unstable_yieldValue('setState2'); @@ -258,7 +224,7 @@ describe('ReactIncremental', () => { }, () => Scheduler.unstable_yieldValue('callback2'), ); - } + }); // Flush the rest of the work which now includes the low priority expect(Scheduler).toFlushAndYield([ @@ -1878,18 +1844,7 @@ describe('ReactIncremental', () => { 'ShowLocale {"locale":"de"}', 'ShowBoth {"locale":"de"}', ]); - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactNoop.render( - - -
- -
-
, - ); - }); - } else { + React.startTransition(() => { ReactNoop.render( @@ -1898,7 +1853,7 @@ describe('ReactIncremental', () => { , ); - } + }); expect(Scheduler).toFlushAndYieldThrough(['Intl {}']); ReactNoop.render( @@ -2028,22 +1983,7 @@ describe('ReactIncremental', () => { } } - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactNoop.render( - - - - - - - - - - , - ); - }); - } else { + React.startTransition(() => { ReactNoop.render( @@ -2056,7 +1996,7 @@ describe('ReactIncremental', () => { , ); - } + }); expect(Scheduler).toFlushAndYieldThrough([ 'Intl {}', 'ShowLocale {"locale":"fr"}', @@ -2746,13 +2686,9 @@ describe('ReactIncremental', () => { return null; } - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactNoop.render(); - }); - } else { + React.startTransition(() => { ReactNoop.render(); - } + }); expect(Scheduler).toFlushAndYieldThrough(['Parent: 1']); // Interrupt at same priority @@ -2772,13 +2708,9 @@ describe('ReactIncremental', () => { return null; } - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactNoop.render(); - }); - } else { + React.startTransition(() => { ReactNoop.render(); - } + }); expect(Scheduler).toFlushAndYieldThrough(['Parent: 1']); // Interrupt at lower priority @@ -2799,13 +2731,9 @@ describe('ReactIncremental', () => { return null; } - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactNoop.render(); - }); - } else { + React.startTransition(() => { ReactNoop.render(); - } + }); expect(Scheduler).toFlushAndYieldThrough(['Parent: 1']); // Interrupt at higher priority diff --git a/packages/react-reconciler/src/__tests__/ReactIncrementalErrorHandling-test.internal.js b/packages/react-reconciler/src/__tests__/ReactIncrementalErrorHandling-test.internal.js index a5c273b25c076..547efa26faf84 100644 --- a/packages/react-reconciler/src/__tests__/ReactIncrementalErrorHandling-test.internal.js +++ b/packages/react-reconciler/src/__tests__/ReactIncrementalErrorHandling-test.internal.js @@ -87,23 +87,7 @@ describe('ReactIncrementalErrorHandling', () => { throw new Error('oops!'); } - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactNoop.render( - - - - - - - - - - - , - ); - }); - } else { + React.startTransition(() => { ReactNoop.render( @@ -117,7 +101,7 @@ describe('ReactIncrementalErrorHandling', () => { , ); - } + }); // Start rendering asynchronously expect(Scheduler).toFlushAndYieldThrough([ @@ -201,23 +185,7 @@ describe('ReactIncrementalErrorHandling', () => { throw new Error('oops!'); } - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactNoop.render( - - - - - - - - - - - , - ); - }); - } else { + React.startTransition(() => { ReactNoop.render( @@ -231,7 +199,7 @@ describe('ReactIncrementalErrorHandling', () => { , ); - } + }); // Start rendering asynchronously expect(Scheduler).toFlushAndYieldThrough([ @@ -399,17 +367,11 @@ describe('ReactIncrementalErrorHandling', () => { ); } - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactNoop.render(, () => - Scheduler.unstable_yieldValue('commit'), - ); - }); - } else { + React.startTransition(() => { ReactNoop.render(, () => Scheduler.unstable_yieldValue('commit'), ); - } + }); // Render the bad component asynchronously expect(Scheduler).toFlushAndYieldThrough(['Parent', 'BadRender']); @@ -451,13 +413,9 @@ describe('ReactIncrementalErrorHandling', () => { ); } - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactNoop.render(); - }); - } else { + React.startTransition(() => { ReactNoop.render(); - } + }); // Render part of the tree expect(Scheduler).toFlushAndYieldThrough(['A', 'B']); @@ -592,21 +550,13 @@ describe('ReactIncrementalErrorHandling', () => { throw new Error('Hello'); } - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactNoop.render( - - - , - ); - }); - } else { + React.startTransition(() => { ReactNoop.render( , ); - } + }); expect(Scheduler).toFlushAndYieldThrough(['ErrorBoundary render success']); expect(ReactNoop).toMatchRenderedOutput(null); @@ -781,21 +731,13 @@ describe('ReactIncrementalErrorHandling', () => { throw new Error('Hello'); } - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactNoop.render( - - - , - ); - }); - } else { + React.startTransition(() => { ReactNoop.render( , ); - } + }); expect(Scheduler).toFlushAndYieldThrough(['RethrowErrorBoundary render']); @@ -1875,13 +1817,9 @@ describe('ReactIncrementalErrorHandling', () => { } await act(async () => { - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - root.render(); - }); - } else { + React.startTransition(() => { root.render(); - } + }); // Render past the component that throws, then yield. expect(Scheduler).toFlushAndYieldThrough(['Oops']); diff --git a/packages/react-reconciler/src/__tests__/ReactIncrementalReflection-test.js b/packages/react-reconciler/src/__tests__/ReactIncrementalReflection-test.js index 45ecb936587eb..319be4c9f2b9f 100644 --- a/packages/react-reconciler/src/__tests__/ReactIncrementalReflection-test.js +++ b/packages/react-reconciler/src/__tests__/ReactIncrementalReflection-test.js @@ -63,13 +63,9 @@ describe('ReactIncrementalReflection', () => { return ; } - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactNoop.render(); - }); - } else { + React.startTransition(() => { ReactNoop.render(); - } + }); // Render part way through but don't yet commit the updates. expect(Scheduler).toFlushAndYieldThrough(['componentWillMount: false']); @@ -117,13 +113,9 @@ describe('ReactIncrementalReflection', () => { expect(instances[0]._isMounted()).toBe(true); - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactNoop.render(); - }); - } else { + React.startTransition(() => { ReactNoop.render(); - } + }); // Render part way through but don't yet commit the updates so it is not // fully unmounted yet. expect(Scheduler).toFlushAndYieldThrough(['Other']); @@ -206,13 +198,9 @@ describe('ReactIncrementalReflection', () => { return [, ]; } - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactNoop.render(); - }); - } else { + React.startTransition(() => { ReactNoop.render(); - } + }); // Flush past Component but don't complete rendering everything yet. expect(Scheduler).toFlushAndYieldThrough([ ['componentWillMount', null], @@ -246,13 +234,9 @@ describe('ReactIncrementalReflection', () => { // The next step will render a new host node but won't get committed yet. // We expect this to mutate the original Fiber. - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactNoop.render(); - }); - } else { + React.startTransition(() => { ReactNoop.render(); - } + }); expect(Scheduler).toFlushAndYieldThrough([ ['componentWillUpdate', hostSpan], 'render', @@ -273,13 +257,9 @@ describe('ReactIncrementalReflection', () => { expect(ReactNoop.findInstance(classInstance)).toBe(hostDiv); // Render to null but don't commit it yet. - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactNoop.render(); - }); - } else { + React.startTransition(() => { ReactNoop.render(); - } + }); expect(Scheduler).toFlushAndYieldThrough([ ['componentWillUpdate', hostDiv], 'render', diff --git a/packages/react-reconciler/src/__tests__/ReactIncrementalScheduling-test.js b/packages/react-reconciler/src/__tests__/ReactIncrementalScheduling-test.js index 3cc006dad1c52..cfb09e497eb12 100644 --- a/packages/react-reconciler/src/__tests__/ReactIncrementalScheduling-test.js +++ b/packages/react-reconciler/src/__tests__/ReactIncrementalScheduling-test.js @@ -105,15 +105,10 @@ describe('ReactIncrementalScheduling', () => { // Schedule deferred work in the reverse order act(() => { - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactNoop.renderToRootWithID(, 'c'); - ReactNoop.renderToRootWithID(, 'b'); - }); - } else { + React.startTransition(() => { ReactNoop.renderToRootWithID(, 'c'); ReactNoop.renderToRootWithID(, 'b'); - } + }); // Ensure it starts in the order it was scheduled expect(Scheduler).toFlushAndYieldThrough(['c:2']); @@ -122,13 +117,9 @@ describe('ReactIncrementalScheduling', () => { expect(ReactNoop.getChildrenAsJSX('c')).toEqual('c:2'); // Schedule last bit of work, it will get processed the last - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactNoop.renderToRootWithID(, 'a'); - }); - } else { + React.startTransition(() => { ReactNoop.renderToRootWithID(, 'a'); - } + }); // Keep performing work in the order it was scheduled expect(Scheduler).toFlushAndYieldThrough(['b:2']); @@ -181,13 +172,9 @@ describe('ReactIncrementalScheduling', () => { } } - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactNoop.render(); - }); - } else { + React.startTransition(() => { ReactNoop.render(); - } + }); // Render without committing expect(Scheduler).toFlushAndYieldThrough(['render: 0']); @@ -201,13 +188,9 @@ describe('ReactIncrementalScheduling', () => { 'componentDidUpdate: 1', ]); - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - instance.setState({tick: 2}); - }); - } else { + React.startTransition(() => { instance.setState({tick: 2}); - } + }); expect(Scheduler).toFlushAndYieldThrough(['render: 2']); expect(ReactNoop.flushNextYield()).toEqual([ 'componentDidUpdate: 2', @@ -310,13 +293,9 @@ describe('ReactIncrementalScheduling', () => { return ; } } - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactNoop.render(); - }); - } else { + React.startTransition(() => { ReactNoop.render(); - } + }); // This should be just enough to complete all the work, but not enough to // commit it. diff --git a/packages/react-reconciler/src/__tests__/ReactIncrementalSideEffects-test.js b/packages/react-reconciler/src/__tests__/ReactIncrementalSideEffects-test.js index 3e4cd2e4f55b5..fd1361de82205 100644 --- a/packages/react-reconciler/src/__tests__/ReactIncrementalSideEffects-test.js +++ b/packages/react-reconciler/src/__tests__/ReactIncrementalSideEffects-test.js @@ -456,13 +456,9 @@ describe('ReactIncrementalSideEffects', () => { , ); - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactNoop.render(); - }); - } else { + React.startTransition(() => { ReactNoop.render(); - } + }); // Flush some of the work without committing expect(Scheduler).toFlushAndYieldThrough(['Foo', 'Bar']); @@ -697,13 +693,9 @@ describe('ReactIncrementalSideEffects', () => { Scheduler.unstable_yieldValue('Foo'); return ; } - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactNoop.render(); - }); - } else { + React.startTransition(() => { ReactNoop.render(); - } + }); // This should be just enough to complete the tree without committing it expect(Scheduler).toFlushAndYieldThrough(['Foo']); expect(ReactNoop.getChildrenAsJSX()).toEqual(null); @@ -712,26 +704,18 @@ describe('ReactIncrementalSideEffects', () => { ReactNoop.flushNextYield(); expect(ReactNoop.getChildrenAsJSX()).toEqual(); - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactNoop.render(); - }); - } else { + React.startTransition(() => { ReactNoop.render(); - } + }); // This should be just enough to complete the tree without committing it expect(Scheduler).toFlushAndYieldThrough(['Foo']); expect(ReactNoop.getChildrenAsJSX()).toEqual(); // This time, before we commit the tree, we update the root component with // new props - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactNoop.render(); - }); - } else { + React.startTransition(() => { ReactNoop.render(); - } + }); expect(ReactNoop.getChildrenAsJSX()).toEqual(); // Now let's commit. We already had a commit that was pending, which will // render 2. diff --git a/packages/react-reconciler/src/__tests__/ReactIncrementalUpdates-test.js b/packages/react-reconciler/src/__tests__/ReactIncrementalUpdates-test.js index 1d6ab92a49b56..de60712c11665 100644 --- a/packages/react-reconciler/src/__tests__/ReactIncrementalUpdates-test.js +++ b/packages/react-reconciler/src/__tests__/ReactIncrementalUpdates-test.js @@ -152,21 +152,11 @@ describe('ReactIncrementalUpdates', () => { } // Schedule some async updates - if ( - gate( - flags => flags.enableSyncDefaultUpdates || flags.enableUnifiedSyncLane, - ) - ) { - React.startTransition(() => { - instance.setState(createUpdate('a')); - instance.setState(createUpdate('b')); - instance.setState(createUpdate('c')); - }); - } else { + React.startTransition(() => { instance.setState(createUpdate('a')); instance.setState(createUpdate('b')); instance.setState(createUpdate('c')); - } + }); // Begin the updates but don't flush them yet expect(Scheduler).toFlushAndYieldThrough(['a', 'b', 'c']); @@ -183,11 +173,7 @@ describe('ReactIncrementalUpdates', () => { }); // The sync updates should have flushed, but not the async ones. - if ( - gate( - flags => flags.enableSyncDefaultUpdates && flags.enableUnifiedSyncLane, - ) - ) { + if (gate(flags => flags.enableUnifiedSyncLane)) { expect(Scheduler).toHaveYielded(['d', 'e', 'f']); expect(ReactNoop).toMatchRenderedOutput(); } else { @@ -199,11 +185,7 @@ describe('ReactIncrementalUpdates', () => { // Now flush the remaining work. Even though e and f were already processed, // they should be processed again, to ensure that the terminal state // is deterministic. - if ( - gate( - flags => flags.enableSyncDefaultUpdates && !flags.enableUnifiedSyncLane, - ) - ) { + if (gate(flags => !flags.enableUnifiedSyncLane)) { expect(Scheduler).toFlushAndYield([ // Since 'g' is in a transition, we'll process 'd' separately first. // That causes us to process 'd' with 'e' and 'f' rebased. @@ -257,21 +239,11 @@ describe('ReactIncrementalUpdates', () => { } // Schedule some async updates - if ( - gate( - flags => flags.enableSyncDefaultUpdates || flags.enableUnifiedSyncLane, - ) - ) { - React.startTransition(() => { - instance.setState(createUpdate('a')); - instance.setState(createUpdate('b')); - instance.setState(createUpdate('c')); - }); - } else { + React.startTransition(() => { instance.setState(createUpdate('a')); instance.setState(createUpdate('b')); instance.setState(createUpdate('c')); - } + }); // Begin the updates but don't flush them yet expect(Scheduler).toFlushAndYieldThrough(['a', 'b', 'c']); @@ -291,11 +263,7 @@ describe('ReactIncrementalUpdates', () => { }); // The sync updates should have flushed, but not the async ones. - if ( - gate( - flags => flags.enableSyncDefaultUpdates && flags.enableUnifiedSyncLane, - ) - ) { + if (gate(flags => flags.enableUnifiedSyncLane)) { expect(Scheduler).toHaveYielded(['d', 'e', 'f']); } else { // Update d was dropped and replaced by e. @@ -306,11 +274,7 @@ describe('ReactIncrementalUpdates', () => { // Now flush the remaining work. Even though e and f were already processed, // they should be processed again, to ensure that the terminal state // is deterministic. - if ( - gate( - flags => flags.enableSyncDefaultUpdates && !flags.enableUnifiedSyncLane, - ) - ) { + if (gate(flags => !flags.enableUnifiedSyncLane)) { expect(Scheduler).toFlushAndYield([ // Since 'g' is in a transition, we'll process 'd' separately first. // That causes us to process 'd' with 'e' and 'f' rebased. @@ -566,13 +530,9 @@ describe('ReactIncrementalUpdates', () => { } act(() => { - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactNoop.render(); - }); - } else { + React.startTransition(() => { ReactNoop.render(); - } + }); flushNextRenderIfExpired(); expect(Scheduler).toHaveYielded([]); expect(Scheduler).toFlushAndYield([ @@ -582,13 +542,9 @@ describe('ReactIncrementalUpdates', () => { ]); Scheduler.unstable_advanceTime(10000); - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - setCount(2); - }); - } else { + React.startTransition(() => { setCount(2); - } + }); flushNextRenderIfExpired(); expect(Scheduler).toHaveYielded([]); }); @@ -607,13 +563,9 @@ describe('ReactIncrementalUpdates', () => { Scheduler.unstable_advanceTime(10000); - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactNoop.render(); - }); - } else { + React.startTransition(() => { ReactNoop.render(); - } + }); flushNextRenderIfExpired(); expect(Scheduler).toHaveYielded([]); }); @@ -624,26 +576,18 @@ describe('ReactIncrementalUpdates', () => { return text; } - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactNoop.render(); - }); - } else { + React.startTransition(() => { ReactNoop.render(); - } + }); Scheduler.unstable_advanceTime(10000); flushNextRenderIfExpired(); expect(Scheduler).toHaveYielded(['A']); Scheduler.unstable_advanceTime(10000); - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactNoop.render(); - }); - } else { + React.startTransition(() => { ReactNoop.render(); - } + }); flushNextRenderIfExpired(); expect(Scheduler).toHaveYielded([]); }); @@ -680,13 +624,9 @@ describe('ReactIncrementalUpdates', () => { expect(root).toMatchRenderedOutput(null); await act(async () => { - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - pushToLog('A'); - }); - } else { + React.startTransition(() => { pushToLog('A'); - } + }); ReactNoop.unstable_runWithPriority(ContinuousEventPriority, () => pushToLog('B'), @@ -749,13 +689,9 @@ describe('ReactIncrementalUpdates', () => { expect(root).toMatchRenderedOutput(null); await act(async () => { - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - pushToLog('A'); - }); - } else { + React.startTransition(() => { pushToLog('A'); - } + }); ReactNoop.unstable_runWithPriority(ContinuousEventPriority, () => pushToLog('B'), ); diff --git a/packages/react-reconciler/src/__tests__/ReactInterleavedUpdates-test.js b/packages/react-reconciler/src/__tests__/ReactInterleavedUpdates-test.js index 153d4d28bd3f7..89d9de5226d9e 100644 --- a/packages/react-reconciler/src/__tests__/ReactInterleavedUpdates-test.js +++ b/packages/react-reconciler/src/__tests__/ReactInterleavedUpdates-test.js @@ -57,78 +57,15 @@ describe('ReactInterleavedUpdates', () => { expect(root).toMatchRenderedOutput('000'); await act(async () => { - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - updateChildren(1); - }); - } else { + React.startTransition(() => { updateChildren(1); - } - // Partially render the children. Only the first one. - expect(Scheduler).toFlushAndYieldThrough([1]); - - // In an interleaved event, schedule an update on each of the children. - // Including the two that haven't rendered yet. - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - updateChildren(2); - }); - } else { - updateChildren(2); - } - - // We should continue rendering without including the interleaved updates. - expect(Scheduler).toFlushUntilNextPaint([1, 1]); - expect(root).toMatchRenderedOutput('111'); - }); - // The interleaved updates flush in a separate render. - expect(Scheduler).toHaveYielded([2, 2, 2]); - expect(root).toMatchRenderedOutput('222'); - }); - - // @gate !enableSyncDefaultUpdates - test('low priority update during an interleaved event is not processed during the current render', async () => { - // Same as previous test, but the interleaved update is lower priority than - // the in-progress render. - const updaters = []; - - function Child() { - const [state, setState] = useState(0); - useEffect(() => { - updaters.push(setState); - }, []); - return ; - } - - function updateChildren(value) { - for (let i = 0; i < updaters.length; i++) { - const setState = updaters[i]; - setState(value); - } - } - - const root = ReactNoop.createRoot(); - - await act(async () => { - root.render( - <> - - - - , - ); - }); - expect(Scheduler).toHaveYielded([0, 0, 0]); - expect(root).toMatchRenderedOutput('000'); - - await act(async () => { - updateChildren(1); + }); // Partially render the children. Only the first one. expect(Scheduler).toFlushAndYieldThrough([1]); // In an interleaved event, schedule an update on each of the children. // Including the two that haven't rendered yet. - startTransition(() => { + React.startTransition(() => { updateChildren(2); }); diff --git a/packages/react-reconciler/src/__tests__/ReactLazy-test.internal.js b/packages/react-reconciler/src/__tests__/ReactLazy-test.internal.js index 5f389b7f74384..627bab2368dc3 100644 --- a/packages/react-reconciler/src/__tests__/ReactLazy-test.internal.js +++ b/packages/react-reconciler/src/__tests__/ReactLazy-test.internal.js @@ -1560,13 +1560,9 @@ describe('ReactLazy', () => { expect(root).toMatchRenderedOutput('AB'); // Swap the position of A and B - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - root.update(); - }); - } else { + React.startTransition(() => { root.update(); - } + }); expect(Scheduler).toFlushAndYield(['Init B2', 'Loading...']); await lazyChildB2; // We need to flush to trigger the second one to load. diff --git a/packages/react-reconciler/src/__tests__/ReactNewContext-test.js b/packages/react-reconciler/src/__tests__/ReactNewContext-test.js index 6f995d164327f..bc9d4283894d3 100644 --- a/packages/react-reconciler/src/__tests__/ReactNewContext-test.js +++ b/packages/react-reconciler/src/__tests__/ReactNewContext-test.js @@ -881,13 +881,9 @@ describe('ReactNewContext', () => { ); } - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactNoop.render(); - }); - } else { + React.startTransition(() => { ReactNoop.render(); - } + }); // Render past the Provider, but don't commit yet expect(Scheduler).toFlushAndYieldThrough(['Foo']); @@ -927,13 +923,9 @@ describe('ReactNewContext', () => { ); } - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactNoop.render(); - }); - } else { + React.startTransition(() => { ReactNoop.render(); - } + }); expect(Scheduler).toFlushAndYield(['Foo', 'Foo']); // Get a new copy of ReactNoop diff --git a/packages/react-reconciler/src/__tests__/ReactSchedulerIntegration-test.js b/packages/react-reconciler/src/__tests__/ReactSchedulerIntegration-test.js index 70344ae700145..8db1a121d8f27 100644 --- a/packages/react-reconciler/src/__tests__/ReactSchedulerIntegration-test.js +++ b/packages/react-reconciler/src/__tests__/ReactSchedulerIntegration-test.js @@ -102,13 +102,9 @@ describe('ReactSchedulerIntegration', () => { scheduleCallback(NormalPriority, () => Scheduler.unstable_yieldValue('C')); // Schedule a React render. React will request a paint after committing it. - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - root.render('Update'); - }); - } else { + React.startTransition(() => { root.render('Update'); - } + }); // Advance time just to be sure the next tasks have lower priority Scheduler.unstable_advanceTime(2000); diff --git a/packages/react-reconciler/src/__tests__/ReactSuspense-test.internal.js b/packages/react-reconciler/src/__tests__/ReactSuspense-test.internal.js index 05483e15c7dc1..9c4ba7794b1fa 100644 --- a/packages/react-reconciler/src/__tests__/ReactSuspense-test.internal.js +++ b/packages/react-reconciler/src/__tests__/ReactSuspense-test.internal.js @@ -124,13 +124,9 @@ describe('ReactSuspense', () => { // Navigate the shell to now render the child content. // This should suspend. - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - root.update(); - }); - } else { + React.startTransition(() => { root.update(); - } + }); expect(Scheduler).toFlushAndYield([ 'Foo', @@ -239,19 +235,7 @@ describe('ReactSuspense', () => { expect(root).toMatchRenderedOutput('Initial'); // The update will suspend. - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - root.update( - <> - }> - - - - - , - ); - }); - } else { + React.startTransition(() => { root.update( <> }> @@ -261,8 +245,7 @@ describe('ReactSuspense', () => { , ); - } - + }); // Yield past the Suspense boundary but don't complete the last sibling. expect(Scheduler).toFlushAndYieldThrough([ 'Suspend!', @@ -396,76 +379,6 @@ describe('ReactSuspense', () => { expect(root).toMatchRenderedOutput('AB'); }); - // @gate !enableSyncDefaultUpdates - it( - 'interrupts current render when something suspends with a ' + - "delay and we've already skipped over a lower priority update in " + - 'a parent', - () => { - function interrupt() { - // React has a heuristic to batch all updates that occur within the same - // event. This is a trick to circumvent that heuristic. - ReactTestRenderer.create('whatever'); - } - - function App({shouldSuspend, step}) { - return ( - <> - - }> - {shouldSuspend ? : null} - - - - - ); - } - - const root = ReactTestRenderer.create(null, { - unstable_isConcurrent: true, - }); - - root.update(); - expect(Scheduler).toFlushAndYield(['A0', 'B0', 'C0']); - expect(root).toMatchRenderedOutput('A0B0C0'); - - // This update will suspend. - root.update(); - - // Do a bit of work - expect(Scheduler).toFlushAndYieldThrough(['A1']); - - // Schedule another update. This will have lower priority because it's - // a transition. - React.startTransition(() => { - root.update(); - }); - - // Interrupt to trigger a restart. - interrupt(); - - expect(Scheduler).toFlushAndYieldThrough([ - // Should have restarted the first update, because of the interruption - 'A1', - 'Suspend! [Async]', - 'Loading...', - 'B1', - ]); - - // Should not have committed loading state - expect(root).toMatchRenderedOutput('A0B0C0'); - - // After suspending, should abort the first update and switch to the - // second update. So, C1 should not appear in the log. - // TODO: This should work even if React does not yield to the main - // thread. Should use same mechanism as selective hydration to interrupt - // the render before the end of the current slice of work. - expect(Scheduler).toFlushAndYield(['A2', 'B2', 'C2']); - - expect(root).toMatchRenderedOutput('A2B2C2'); - }, - ); - it('mounts a lazy class component in non-concurrent mode', async () => { class Class extends React.Component { componentDidMount() { diff --git a/packages/react-reconciler/src/__tests__/ReactSuspenseList-test.js b/packages/react-reconciler/src/__tests__/ReactSuspenseList-test.js index 8ff0f35c70fae..701d23854993d 100644 --- a/packages/react-reconciler/src/__tests__/ReactSuspenseList-test.js +++ b/packages/react-reconciler/src/__tests__/ReactSuspenseList-test.js @@ -1362,13 +1362,9 @@ describe('ReactSuspenseList', () => { } // This render is only CPU bound. Nothing suspends. - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactNoop.render(); - }); - } else { + React.startTransition(() => { ReactNoop.render(); - } + }); expect(Scheduler).toFlushAndYieldThrough(['A']); @@ -1546,13 +1542,9 @@ describe('ReactSuspenseList', () => { } // This render is only CPU bound. Nothing suspends. - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactNoop.render(); - }); - } else { + React.startTransition(() => { ReactNoop.render(); - } + }); expect(Scheduler).toFlushAndYieldThrough(['A']); @@ -2548,15 +2540,9 @@ describe('ReactSuspenseList', () => { expect(ReactNoop).toMatchRenderedOutput(null); await act(async () => { - // Add a few items at the end. - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - updateLowPri(true); - }); - } else { + React.startTransition(() => { updateLowPri(true); - } - + }); // Flush partially through. expect(Scheduler).toFlushAndYieldThrough(['B', 'C']); @@ -2692,14 +2678,9 @@ describe('ReactSuspenseList', () => { ); } - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactNoop.render(); - }); - } else { + React.startTransition(() => { ReactNoop.render(); - } - + }); expect(Scheduler).toFlushAndYieldThrough([ 'App', 'First Pass A', @@ -2765,14 +2746,9 @@ describe('ReactSuspenseList', () => { ); } - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactNoop.render(); - }); - } else { + React.startTransition(() => { ReactNoop.render(); - } - + }); expect(Scheduler).toFlushAndYieldThrough([ 'App', 'First Pass A', diff --git a/packages/react-reconciler/src/__tests__/ReactSuspenseWithNoopRenderer-test.js b/packages/react-reconciler/src/__tests__/ReactSuspenseWithNoopRenderer-test.js index aad8729adde1c..c73cd296b8695 100644 --- a/packages/react-reconciler/src/__tests__/ReactSuspenseWithNoopRenderer-test.js +++ b/packages/react-reconciler/src/__tests__/ReactSuspenseWithNoopRenderer-test.js @@ -205,13 +205,9 @@ describe('ReactSuspenseWithNoopRenderer', () => { ); } - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactNoop.render(); - }); - } else { + React.startTransition(() => { ReactNoop.render(); - } + }); expect(Scheduler).toFlushAndYieldThrough([ 'Foo', 'Bar', @@ -281,13 +277,9 @@ describe('ReactSuspenseWithNoopRenderer', () => { expect(Scheduler).toFlushAndYield(['Foo']); // The update will suspend. - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactNoop.render(); - }); - } else { + React.startTransition(() => { ReactNoop.render(); - } + }); expect(Scheduler).toFlushAndYield([ 'Foo', 'Bar', @@ -368,18 +360,7 @@ describe('ReactSuspenseWithNoopRenderer', () => { ReactNoop.render(} />); expect(Scheduler).toFlushAndYield([]); // B suspends. Continue rendering the remaining siblings. - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactNoop.render( - }> - - - - - , - ); - }); - } else { + React.startTransition(() => { ReactNoop.render( }> @@ -388,7 +369,7 @@ describe('ReactSuspenseWithNoopRenderer', () => { , ); - } + }); // B suspends. Continue rendering the remaining siblings. expect(Scheduler).toFlushAndYield([ 'A', @@ -452,13 +433,9 @@ describe('ReactSuspenseWithNoopRenderer', () => { expect(Scheduler).toFlushAndYield([]); expect(ReactNoop).toMatchRenderedOutput(null); - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactNoop.render(); - }); - } else { + React.startTransition(() => { ReactNoop.render(); - } + }); expect(Scheduler).toFlushAndYield(['Suspend! [Result]', 'Loading...']); expect(ReactNoop).toMatchRenderedOutput(null); @@ -603,26 +580,18 @@ describe('ReactSuspenseWithNoopRenderer', () => { expect(Scheduler).toFlushAndYield([]); expect(ReactNoop).toMatchRenderedOutput(null); - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactNoop.render(); - }); - } else { + React.startTransition(() => { ReactNoop.render(); - } + }); expect(Scheduler).toFlushAndYield(['Suspend! [A]', 'Loading...']); expect(ReactNoop).toMatchRenderedOutput(null); // Advance React's virtual time by enough to fall into a new async bucket, // but not enough to expire the suspense timeout. ReactNoop.expire(120); - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactNoop.render(); - }); - } else { + React.startTransition(() => { ReactNoop.render(); - } + }); expect(Scheduler).toFlushAndYield(['Suspend! [A]', 'B', 'Loading...']); expect(ReactNoop).toMatchRenderedOutput(null); @@ -704,35 +673,23 @@ describe('ReactSuspenseWithNoopRenderer', () => { // Schedule an update at several distinct expiration times await act(async () => { - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - root.render(); - }); - } else { + React.startTransition(() => { root.render(); - } + }); Scheduler.unstable_advanceTime(1000); expect(Scheduler).toFlushAndYieldThrough(['Sibling']); interrupt(); - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - root.render(); - }); - } else { + React.startTransition(() => { root.render(); - } + }); Scheduler.unstable_advanceTime(1000); expect(Scheduler).toFlushAndYieldThrough(['Sibling']); interrupt(); - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - root.render(); - }); - } else { + React.startTransition(() => { root.render(); - } + }); Scheduler.unstable_advanceTime(1000); expect(Scheduler).toFlushAndYieldThrough(['Sibling']); interrupt(); @@ -1049,18 +1006,7 @@ describe('ReactSuspenseWithNoopRenderer', () => { ); expect(Scheduler).toFlushAndYield([]); expect(root).toMatchRenderedOutput(null); - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - root.render( - <> - }> - - - - , - ); - }); - } else { + React.startTransition(() => { root.render( <> }> @@ -1069,7 +1015,7 @@ describe('ReactSuspenseWithNoopRenderer', () => { , ); - } + }); expect(Scheduler).toFlushAndYieldThrough(['Suspend! [Async]', 'Sibling']); await resolveText('Async'); @@ -1135,21 +1081,13 @@ describe('ReactSuspenseWithNoopRenderer', () => { ReactNoop.render(} />); expect(Scheduler).toFlushAndYield([]); - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactNoop.render( - }> - - , - ); - }); - } else { + React.startTransition(() => { ReactNoop.render( }> , ); - } + }); expect(Scheduler).toFlushAndYield(['Suspend! [Async]', 'Loading...']); expect(ReactNoop).toMatchRenderedOutput(null); @@ -1954,13 +1892,9 @@ describe('ReactSuspenseWithNoopRenderer', () => { ReactNoop.render(); expect(Scheduler).toFlushAndYield(['Foo']); - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactNoop.render(); - }); - } else { + React.startTransition(() => { ReactNoop.render(); - } + }); Scheduler.unstable_advanceTime(100); await advanceTimers(100); // Start rendering @@ -1989,22 +1923,14 @@ describe('ReactSuspenseWithNoopRenderer', () => { await advanceTimers(500); // No need to rerender. expect(Scheduler).toFlushWithoutYielding(); - if (gate(flags => flags.enableSyncDefaultUpdates)) { - // Since this is a transition, we never fallback. - expect(ReactNoop).toMatchRenderedOutput(null); - } else { - expect(ReactNoop).toMatchRenderedOutput(); - } + // Since this is a transition, we never fallback. + expect(ReactNoop).toMatchRenderedOutput(null); // Flush the promise completely await resolveText('A'); // Renders successfully - if (gate(flags => flags.enableSyncDefaultUpdates)) { - // TODO: Why does this render Foo - expect(Scheduler).toFlushAndYield(['Foo', 'A']); - } else { - expect(Scheduler).toFlushAndYield(['A']); - } + // TODO: Why does this render Foo + expect(Scheduler).toFlushAndYield(['Foo', 'A']); expect(ReactNoop).toMatchRenderedOutput(); }); @@ -2138,13 +2064,9 @@ describe('ReactSuspenseWithNoopRenderer', () => { ReactNoop.render(); expect(Scheduler).toFlushAndYield(['Foo']); - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactNoop.render(); - }); - } else { + React.startTransition(() => { ReactNoop.render(); - } + }); expect(Scheduler).toFlushAndYieldThrough(['Foo']); // Advance some time. @@ -2169,12 +2091,8 @@ describe('ReactSuspenseWithNoopRenderer', () => { // updates as way earlier in the past. This test ensures that we don't // use this assumption to add a very long JND. expect(Scheduler).toFlushWithoutYielding(); - if (gate(flags => flags.enableSyncDefaultUpdates)) { - // Transitions never fallback. - expect(ReactNoop).toMatchRenderedOutput(null); - } else { - expect(ReactNoop).toMatchRenderedOutput(); - } + // Transitions never fallback. + expect(ReactNoop).toMatchRenderedOutput(null); }); // TODO: flip to "warns" when this is implemented again. @@ -2542,13 +2460,9 @@ describe('ReactSuspenseWithNoopRenderer', () => { expect(Scheduler).toFlushAndYield(['Foo', 'A']); expect(ReactNoop).toMatchRenderedOutput(); - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactNoop.render(); - }); - } else { + React.startTransition(() => { ReactNoop.render(); - } + }); expect(Scheduler).toFlushAndYield([ 'Foo', @@ -2563,17 +2477,8 @@ describe('ReactSuspenseWithNoopRenderer', () => { Scheduler.unstable_advanceTime(600); await advanceTimers(600); - if (gate(flags => flags.enableSyncDefaultUpdates)) { - // Transitions never fall back. - expect(ReactNoop).toMatchRenderedOutput(); - } else { - expect(ReactNoop).toMatchRenderedOutput( - <> - - - , - ); - } + // Transitions never fall back. + expect(ReactNoop).toMatchRenderedOutput(); }); // @gate enableLegacyCache @@ -2598,13 +2503,9 @@ describe('ReactSuspenseWithNoopRenderer', () => { expect(Scheduler).toFlushAndYield(['Foo', 'A']); expect(ReactNoop).toMatchRenderedOutput(); - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactNoop.render(); - }); - } else { + React.startTransition(() => { ReactNoop.render(); - } + }); expect(Scheduler).toFlushAndYield([ 'Foo', @@ -2619,12 +2520,8 @@ describe('ReactSuspenseWithNoopRenderer', () => { Scheduler.unstable_advanceTime(600); await advanceTimers(600); - if (gate(flags => flags.enableSyncDefaultUpdates)) { - // Transitions never fall back. - expect(ReactNoop).toMatchRenderedOutput(); - } else { - expect(ReactNoop).toMatchRenderedOutput(); - } + // Transitions never fall back. + expect(ReactNoop).toMatchRenderedOutput(); }); // @gate enableLegacyCache @@ -3160,26 +3057,18 @@ describe('ReactSuspenseWithNoopRenderer', () => { await act(async () => { // Update. Since showing a fallback would hide content that's already // visible, it should suspend for a JND without committing. - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - root.render(); - }); - } else { + React.startTransition(() => { root.render(); - } + }); expect(Scheduler).toFlushAndYield(['Suspend! [First update]']); // Should not display a fallback expect(root).toMatchRenderedOutput(); // Update again. This should also suspend for a JND. - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - root.render(); - }); - } else { + React.startTransition(() => { root.render(); - } + }); expect(Scheduler).toFlushAndYield(['Suspend! [Second update]']); // Should not display a fallback @@ -3951,117 +3840,6 @@ describe('ReactSuspenseWithNoopRenderer', () => { ); }); - // @gate enableLegacyCache - // @gate !enableSyncDefaultUpdates - it('regression: ping at high priority causes update to be dropped', async () => { - const {useState, useTransition} = React; - - let setTextA; - function A() { - const [textA, _setTextA] = useState('A'); - setTextA = _setTextA; - return ( - }> - - - ); - } - - let setTextB; - let startTransition; - function B() { - const [textB, _setTextB] = useState('B'); - // eslint-disable-next-line no-unused-vars - const [_, _startTransition] = useTransition(); - startTransition = _startTransition; - setTextB = _setTextB; - return ( - }> - - - ); - } - - function App() { - return ( - <> - - - - ); - } - - const root = ReactNoop.createRoot(); - await act(async () => { - await seedNextTextCache('A'); - await seedNextTextCache('B'); - root.render(); - }); - expect(Scheduler).toHaveYielded(['A', 'B']); - expect(root).toMatchRenderedOutput( - <> - - - , - ); - - await act(async () => { - // Triggers suspense at normal pri - setTextA('A1'); - // Triggers in an unrelated tree at a different pri - startTransition(() => { - // Update A again so that it doesn't suspend on A1. That way we can ping - // the A1 update without also pinging this one. This is a workaround - // because there's currently no way to render at a lower priority (B2) - // without including all updates at higher priority (A1). - setTextA('A2'); - setTextB('B2'); - }); - - expect(Scheduler).toFlushAndYield([ - 'B', - 'Suspend! [A1]', - 'Loading...', - - 'Suspend! [A2]', - 'Loading...', - 'Suspend! [B2]', - 'Loading...', - ]); - expect(root).toMatchRenderedOutput( - <> - - - , - ); - - await resolveText('A1'); - expect(Scheduler).toFlushAndYield([ - 'A1', - 'Suspend! [A2]', - 'Loading...', - 'Suspend! [B2]', - 'Loading...', - ]); - expect(root).toMatchRenderedOutput( - <> - - - , - ); - - await resolveText('A2'); - await resolveText('B2'); - }); - expect(Scheduler).toHaveYielded(['A2', 'B2']); - expect(root).toMatchRenderedOutput( - <> - - - , - ); - }); - // Regression: https://github.com/facebook/react/issues/18486 // @gate enableLegacyCache it('does not get stuck in pending state with render phase updates', async () => { diff --git a/packages/react-reconciler/src/__tests__/useMutableSource-test.internal.js b/packages/react-reconciler/src/__tests__/useMutableSource-test.internal.js index 27046562c9709..2ce13bf613f18 100644 --- a/packages/react-reconciler/src/__tests__/useMutableSource-test.internal.js +++ b/packages/react-reconciler/src/__tests__/useMutableSource-test.internal.js @@ -215,27 +215,7 @@ describe('useMutableSource', () => { const mutableSource = createMutableSource(source, param => param.version); act(() => { - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactNoop.render( - <> - - - , - () => Scheduler.unstable_yieldValue('Sync effect'), - ); - }); - } else { + React.startTransition(() => { ReactNoop.render( <> { , () => Scheduler.unstable_yieldValue('Sync effect'), ); - } + }); // Do enough work to read from one component expect(Scheduler).toFlushAndYieldThrough(['a:one']); @@ -454,13 +434,9 @@ describe('useMutableSource', () => { // Changing values should schedule an update with React. // Start working on this update but don't finish it. - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - source.value = 'two'; - }); - } else { + React.startTransition(() => { source.value = 'two'; - } + }); expect(Scheduler).toFlushAndYieldThrough(['a:two']); // Re-renders that occur before the update is processed @@ -724,33 +700,7 @@ describe('useMutableSource', () => { // Because the store has not changed yet, there are no pending updates, // so it is considered safe to read from when we start this render. - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactNoop.render( - <> - - - - , - () => Scheduler.unstable_yieldValue('Sync effect'), - ); - }); - } else { + React.startTransition(() => { ReactNoop.render( <> { , () => Scheduler.unstable_yieldValue('Sync effect'), ); - } + }); expect(Scheduler).toFlushAndYieldThrough(['a:a:one', 'b:b:one']); // Mutating the source should trigger a tear detection on the next read, @@ -865,26 +815,7 @@ describe('useMutableSource', () => { act(() => { // Start a render that uses the mutable source. - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactNoop.render( - <> - - - , - ); - }); - } else { + React.startTransition(() => { ReactNoop.render( <> { /> , ); - } + }); expect(Scheduler).toFlushAndYieldThrough(['a:one']); // Mutate source @@ -1535,17 +1466,7 @@ describe('useMutableSource', () => { expect(root).toMatchRenderedOutput('a0'); await act(async () => { - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - root.render( - <> - - - - , - ); - }); - } else { + React.startTransition(() => { root.render( <> @@ -1553,7 +1474,7 @@ describe('useMutableSource', () => { , ); - } + }); expect(Scheduler).toFlushAndYieldThrough(['a0', 'b0']); // Mutate in an event. This schedules a subscription update on a, which @@ -1689,13 +1610,9 @@ describe('useMutableSource', () => { await act(async () => { // Switch the parent and the child to read using the same config - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - root.render(); - }); - } else { + React.startTransition(() => { root.render(); - } + }); // Start rendering the parent, but yield before rendering the child expect(Scheduler).toFlushAndYieldThrough(['Parent: 2']); @@ -1706,41 +1623,19 @@ describe('useMutableSource', () => { source.valueB = '3'; }); - if (gate(flags => flags.enableSyncDefaultUpdates)) { - // In default sync mode, all of the updates flush sync. - expect(Scheduler).toFlushAndYieldThrough([ - // The partial render completes - 'Child: 2', - 'Commit: 2, 2', - 'Parent: 3', - 'Child: 3', - ]); - - expect(Scheduler).toFlushAndYield([ - // Now finish the rest of the update - 'Commit: 3, 3', - ]); - } else { - expect(Scheduler).toFlushAndYieldThrough([ - // The partial render completes - 'Child: 2', - 'Commit: 2, 2', - ]); - - // Now there are two pending mutations at different priorities. But they - // both read the same version of the mutable source, so we must render - // them simultaneously. - // - expect(Scheduler).toFlushAndYieldThrough([ - 'Parent: 3', - // Demonstrates that we can yield here - ]); - expect(Scheduler).toFlushAndYield([ - // Now finish the rest of the update - 'Child: 3', - 'Commit: 3, 3', - ]); - } + // In default sync mode, all of the updates flush sync. + expect(Scheduler).toFlushAndYieldThrough([ + // The partial render completes + 'Child: 2', + 'Commit: 2, 2', + 'Parent: 3', + 'Child: 3', + ]); + + expect(Scheduler).toFlushAndYield([ + // Now finish the rest of the update + 'Commit: 3, 3', + ]); }); }); @@ -1860,26 +1755,7 @@ describe('useMutableSource', () => { act(() => { // Start a render that uses the mutable source. - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactNoop.render( - <> - - - , - ); - }); - } else { + React.startTransition(() => { ReactNoop.render( <> { /> , ); - } + }); expect(Scheduler).toFlushAndYieldThrough(['a:one']); const PrevScheduler = Scheduler; @@ -1941,26 +1817,7 @@ describe('useMutableSource', () => { act(() => { // Start a render that uses the mutable source. - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactNoop.render( - <> - - - , - ); - }); - } else { + React.startTransition(() => { ReactNoop.render( <> { /> , ); - } + }); expect(Scheduler).toFlushAndYieldThrough(['a:one']); const PrevScheduler = Scheduler; diff --git a/packages/react-reconciler/src/__tests__/useMutableSourceHydration-test.js b/packages/react-reconciler/src/__tests__/useMutableSourceHydration-test.js index ac709916ce381..48e56959c0a02 100644 --- a/packages/react-reconciler/src/__tests__/useMutableSourceHydration-test.js +++ b/packages/react-reconciler/src/__tests__/useMutableSourceHydration-test.js @@ -254,23 +254,14 @@ describe('useMutableSourceHydration', () => { expect(() => { act(() => { - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactDOMClient.hydrateRoot(container, , { - mutableSources: [mutableSource], - onRecoverableError(error) { - Scheduler.unstable_yieldValue('Log error: ' + error.message); - }, - }); - }); - } else { + React.startTransition(() => { ReactDOMClient.hydrateRoot(container, , { mutableSources: [mutableSource], onRecoverableError(error) { Scheduler.unstable_yieldValue('Log error: ' + error.message); }, }); - } + }); expect(Scheduler).toFlushAndYieldThrough(['a:one']); source.value = 'two'; }); @@ -347,23 +338,14 @@ describe('useMutableSourceHydration', () => { /> ); - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactDOMClient.hydrateRoot(container, fragment, { - mutableSources: [mutableSource], - onRecoverableError(error) { - Scheduler.unstable_yieldValue('Log error: ' + error.message); - }, - }); - }); - } else { + React.startTransition(() => { ReactDOMClient.hydrateRoot(container, fragment, { mutableSources: [mutableSource], onRecoverableError(error) { Scheduler.unstable_yieldValue('Log error: ' + error.message); }, }); - } + }); expect(Scheduler).toFlushAndYieldThrough(['0:a:one']); source.valueB = 'b:two'; }); diff --git a/packages/react-test-renderer/src/__tests__/ReactTestRendererAsync-test.js b/packages/react-test-renderer/src/__tests__/ReactTestRendererAsync-test.js index 03379563c7e59..de0fe8371431f 100644 --- a/packages/react-test-renderer/src/__tests__/ReactTestRendererAsync-test.js +++ b/packages/react-test-renderer/src/__tests__/ReactTestRendererAsync-test.js @@ -89,17 +89,11 @@ describe('ReactTestRendererAsync', () => { } let renderer; - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - renderer = ReactTestRenderer.create(, { - unstable_isConcurrent: true, - }); - }); - } else { + React.startTransition(() => { renderer = ReactTestRenderer.create(, { unstable_isConcurrent: true, }); - } + }); // Flush the first two siblings expect(Scheduler).toFlushAndYieldThrough(['A:1', 'B:1']); @@ -135,17 +129,11 @@ describe('ReactTestRendererAsync', () => { } let renderer; - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - renderer = ReactTestRenderer.create(, { - unstable_isConcurrent: true, - }); - }); - } else { + React.startTransition(() => { renderer = ReactTestRenderer.create(, { unstable_isConcurrent: true, }); - } + }); // Flush the some of the changes, but don't commit expect(Scheduler).toFlushAndYieldThrough(['A:1']); diff --git a/packages/react/src/__tests__/ReactProfiler-test.internal.js b/packages/react/src/__tests__/ReactProfiler-test.internal.js index ba8f049a4370f..c9e124ec7790a 100644 --- a/packages/react/src/__tests__/ReactProfiler-test.internal.js +++ b/packages/react/src/__tests__/ReactProfiler-test.internal.js @@ -196,19 +196,7 @@ describe(`onRender`, () => { return null; }; - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactTestRenderer.create( - - - - , - { - unstable_isConcurrent: true, - }, - ); - }); - } else { + React.startTransition(() => { ReactTestRenderer.create( @@ -218,7 +206,7 @@ describe(`onRender`, () => { unstable_isConcurrent: true, }, ); - } + }); // Times are logged until a render is committed. expect(Scheduler).toFlushAndYieldThrough(['first']); @@ -744,17 +732,7 @@ describe(`onRender`, () => { Scheduler.unstable_advanceTime(5); // 0 -> 5 // Render partially, but run out of time before completing. - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactTestRenderer.create( - - - - , - {unstable_isConcurrent: true}, - ); - }); - } else { + React.startTransition(() => { ReactTestRenderer.create( @@ -762,7 +740,7 @@ describe(`onRender`, () => { , {unstable_isConcurrent: true}, ); - } + }); expect(Scheduler).toFlushAndYieldThrough(['Yield:2']); expect(callback).toHaveBeenCalledTimes(0); @@ -791,20 +769,7 @@ describe(`onRender`, () => { // Render partially, but don't finish. // This partial render should take 5ms of simulated time. - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactTestRenderer.create( - - - - - - - , - {unstable_isConcurrent: true}, - ); - }); - } else { + React.startTransition(() => { ReactTestRenderer.create( @@ -815,7 +780,7 @@ describe(`onRender`, () => { , {unstable_isConcurrent: true}, ); - } + }); expect(Scheduler).toFlushAndYieldThrough(['Yield:5']); expect(callback).toHaveBeenCalledTimes(0); @@ -857,17 +822,7 @@ describe(`onRender`, () => { // Render a partially update, but don't finish. // This partial render should take 10ms of simulated time. let renderer; - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - renderer = ReactTestRenderer.create( - - - - , - {unstable_isConcurrent: true}, - ); - }); - } else { + React.startTransition(() => { renderer = ReactTestRenderer.create( @@ -875,7 +830,7 @@ describe(`onRender`, () => { , {unstable_isConcurrent: true}, ); - } + }); expect(Scheduler).toFlushAndYieldThrough(['Yield:10']); expect(callback).toHaveBeenCalledTimes(0); @@ -944,17 +899,7 @@ describe(`onRender`, () => { // Render a partially update, but don't finish. // This partial render should take 3ms of simulated time. - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - renderer.update( - - - - - , - ); - }); - } else { + React.startTransition(() => { renderer.update( @@ -962,7 +907,7 @@ describe(`onRender`, () => { , ); - } + }); expect(Scheduler).toFlushAndYieldThrough(['Yield:3']); expect(callback).toHaveBeenCalledTimes(0); @@ -1068,13 +1013,9 @@ describe(`onRender`, () => { // Render a partially update, but don't finish. // This partial render will take 10ms of actual render time. - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - first.setState({renderTime: 10}); - }); - } else { + React.startTransition(() => { first.setState({renderTime: 10}); - } + }); expect(Scheduler).toFlushAndYieldThrough(['FirstComponent:10']); expect(callback).toHaveBeenCalledTimes(0); diff --git a/packages/react/src/__tests__/ReactProfilerDevToolsIntegration-test.internal.js b/packages/react/src/__tests__/ReactProfilerDevToolsIntegration-test.internal.js index a0fef0cb23139..faa0ade612764 100644 --- a/packages/react/src/__tests__/ReactProfilerDevToolsIntegration-test.internal.js +++ b/packages/react/src/__tests__/ReactProfilerDevToolsIntegration-test.internal.js @@ -155,13 +155,9 @@ describe('ReactProfiler DevTools integration', () => { // for updates. Scheduler.unstable_advanceTime(10000); // Schedule an update. - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - root.update(); - }); - } else { + React.startTransition(() => { root.update(); - } + }); // Update B should not instantly expire. expect(Scheduler).toFlushAndYieldThrough([]); diff --git a/packages/shared/ReactFeatureFlags.js b/packages/shared/ReactFeatureFlags.js index e6f890e9992ed..b3da065e1374d 100644 --- a/packages/shared/ReactFeatureFlags.js +++ b/packages/shared/ReactFeatureFlags.js @@ -135,9 +135,6 @@ export const disableLegacyContext = false; export const enableUseRefAccessWarning = false; -// Enables time slicing for updates that aren't wrapped in startTransition. -export const enableSyncDefaultUpdates = true; - export const enableUnifiedSyncLane = __EXPERIMENTAL__; // Adds an opt-in to time slicing for updates that aren't wrapped in diff --git a/packages/shared/forks/ReactFeatureFlags.native-fb.js b/packages/shared/forks/ReactFeatureFlags.native-fb.js index dc8a42920b8aa..7482b84e7cf96 100644 --- a/packages/shared/forks/ReactFeatureFlags.native-fb.js +++ b/packages/shared/forks/ReactFeatureFlags.native-fb.js @@ -67,7 +67,6 @@ export const createRootStrictEffectsByDefault = false; export const disableSchedulerTimeoutInWorkLoop = false; export const enableLazyContextPropagation = false; export const enableLegacyHidden = true; -export const enableSyncDefaultUpdates = true; export const enableUnifiedSyncLane = false; export const allowConcurrentByDefault = true; export const enableCustomElementPropertySupport = false; diff --git a/packages/shared/forks/ReactFeatureFlags.native-oss.js b/packages/shared/forks/ReactFeatureFlags.native-oss.js index 77dca5a86dae4..29259deed6ecc 100644 --- a/packages/shared/forks/ReactFeatureFlags.native-oss.js +++ b/packages/shared/forks/ReactFeatureFlags.native-oss.js @@ -58,7 +58,6 @@ export const enableUseRefAccessWarning = false; export const disableSchedulerTimeoutInWorkLoop = false; export const enableLazyContextPropagation = false; export const enableLegacyHidden = false; -export const enableSyncDefaultUpdates = true; export const enableUnifiedSyncLane = false; export const allowConcurrentByDefault = false; export const enableCustomElementPropertySupport = false; diff --git a/packages/shared/forks/ReactFeatureFlags.test-renderer.js b/packages/shared/forks/ReactFeatureFlags.test-renderer.js index 4fec0051cb6ff..2e0079d5eccf8 100644 --- a/packages/shared/forks/ReactFeatureFlags.test-renderer.js +++ b/packages/shared/forks/ReactFeatureFlags.test-renderer.js @@ -58,7 +58,6 @@ export const enableUseRefAccessWarning = false; export const disableSchedulerTimeoutInWorkLoop = false; export const enableLazyContextPropagation = false; export const enableLegacyHidden = false; -export const enableSyncDefaultUpdates = true; export const enableUnifiedSyncLane = __EXPERIMENTAL__; export const allowConcurrentByDefault = false; export const enableCustomElementPropertySupport = false; diff --git a/packages/shared/forks/ReactFeatureFlags.test-renderer.native.js b/packages/shared/forks/ReactFeatureFlags.test-renderer.native.js index 77aaf9e979490..92f5a8ed4eda1 100644 --- a/packages/shared/forks/ReactFeatureFlags.test-renderer.native.js +++ b/packages/shared/forks/ReactFeatureFlags.test-renderer.native.js @@ -57,7 +57,6 @@ export const enableUseRefAccessWarning = false; export const disableSchedulerTimeoutInWorkLoop = false; export const enableLazyContextPropagation = false; export const enableLegacyHidden = false; -export const enableSyncDefaultUpdates = true; export const enableUnifiedSyncLane = false; export const allowConcurrentByDefault = true; diff --git a/packages/shared/forks/ReactFeatureFlags.test-renderer.www.js b/packages/shared/forks/ReactFeatureFlags.test-renderer.www.js index 6f639b86d6594..c3ccf711f766f 100644 --- a/packages/shared/forks/ReactFeatureFlags.test-renderer.www.js +++ b/packages/shared/forks/ReactFeatureFlags.test-renderer.www.js @@ -58,7 +58,6 @@ export const enableUseRefAccessWarning = false; export const disableSchedulerTimeoutInWorkLoop = false; export const enableLazyContextPropagation = false; export const enableLegacyHidden = false; -export const enableSyncDefaultUpdates = true; export const enableUnifiedSyncLane = false; export const allowConcurrentByDefault = true; export const enableCustomElementPropertySupport = false; diff --git a/packages/shared/forks/ReactFeatureFlags.testing.js b/packages/shared/forks/ReactFeatureFlags.testing.js index fc6f6d8148004..ee17c5053ef86 100644 --- a/packages/shared/forks/ReactFeatureFlags.testing.js +++ b/packages/shared/forks/ReactFeatureFlags.testing.js @@ -58,7 +58,6 @@ export const enableUseRefAccessWarning = false; export const disableSchedulerTimeoutInWorkLoop = false; export const enableLazyContextPropagation = false; export const enableLegacyHidden = false; -export const enableSyncDefaultUpdates = true; export const enableUnifiedSyncLane = __EXPERIMENTAL__; export const allowConcurrentByDefault = false; export const enableCustomElementPropertySupport = false; diff --git a/packages/shared/forks/ReactFeatureFlags.testing.www.js b/packages/shared/forks/ReactFeatureFlags.testing.www.js index 02aebb0b0e223..9cbb2929c1a81 100644 --- a/packages/shared/forks/ReactFeatureFlags.testing.www.js +++ b/packages/shared/forks/ReactFeatureFlags.testing.www.js @@ -58,7 +58,6 @@ export const enableUseRefAccessWarning = false; export const disableSchedulerTimeoutInWorkLoop = false; export const enableLazyContextPropagation = false; export const enableLegacyHidden = false; -export const enableSyncDefaultUpdates = true; export const enableUnifiedSyncLane = __EXPERIMENTAL__; export const allowConcurrentByDefault = true; export const enableCustomElementPropertySupport = false; diff --git a/packages/shared/forks/ReactFeatureFlags.www-dynamic.js b/packages/shared/forks/ReactFeatureFlags.www-dynamic.js index 42e9c8a7ab2f4..c754e18430701 100644 --- a/packages/shared/forks/ReactFeatureFlags.www-dynamic.js +++ b/packages/shared/forks/ReactFeatureFlags.www-dynamic.js @@ -21,7 +21,6 @@ export const enableUseRefAccessWarning = __VARIANT__; export const enableProfilerNestedUpdateScheduledHook = __VARIANT__; export const disableSchedulerTimeoutInWorkLoop = __VARIANT__; export const enableLazyContextPropagation = __VARIANT__; -export const enableSyncDefaultUpdates = __VARIANT__; export const enableUnifiedSyncLane = __VARIANT__; export const enableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay = __VARIANT__; diff --git a/packages/shared/forks/ReactFeatureFlags.www.js b/packages/shared/forks/ReactFeatureFlags.www.js index edbc49557aaa6..aa247e2c23b53 100644 --- a/packages/shared/forks/ReactFeatureFlags.www.js +++ b/packages/shared/forks/ReactFeatureFlags.www.js @@ -28,7 +28,6 @@ export const { disableNativeComponentFrames, disableSchedulerTimeoutInWorkLoop, enableLazyContextPropagation, - enableSyncDefaultUpdates, enableUnifiedSyncLane, enableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay, enableTransitionTracing, diff --git a/packages/use-subscription/src/__tests__/useSubscription-test.js b/packages/use-subscription/src/__tests__/useSubscription-test.js index ee89c3dbb9562..aefef75ff9fd7 100644 --- a/packages/use-subscription/src/__tests__/useSubscription-test.js +++ b/packages/use-subscription/src/__tests__/useSubscription-test.js @@ -331,13 +331,9 @@ describe('useSubscription', () => { // Start React update, but don't finish act(() => { - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - renderer.update(); - }); - } else { + React.startTransition(() => { renderer.update(); - } + }); expect(Scheduler).toFlushAndYieldThrough(['Child: b-0']); expect(log).toEqual(['Parent.componentDidMount']); @@ -439,13 +435,9 @@ describe('useSubscription', () => { // Start React update, but don't finish act(() => { - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - renderer.update(); - }); - } else { + React.startTransition(() => { renderer.update(); - } + }); expect(Scheduler).toFlushAndYieldThrough(['Child: b-0']); expect(log).toEqual([]); @@ -623,24 +615,16 @@ describe('useSubscription', () => { // Interrupt with a second mutation "C" -> "D". // This update will not be eagerly evaluated, // but useSubscription() should eagerly close over the updated value to avoid tearing. - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - mutate('C'); - }); - } else { + React.startTransition(() => { mutate('C'); - } + }); expect(Scheduler).toFlushAndYieldThrough([ 'render:first:C', 'render:second:C', ]); - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - mutate('D'); - }); - } else { + React.startTransition(() => { mutate('D'); - } + }); expect(Scheduler).toFlushAndYield(['render:first:D', 'render:second:D']); // No more pending updates