diff --git a/packages/react-art/src/__tests__/ReactART-test.js b/packages/react-art/src/__tests__/ReactART-test.js index 9f73006d0201a..714e19d1cc1fe 100644 --- a/packages/react-art/src/__tests__/ReactART-test.js +++ b/packages/react-art/src/__tests__/ReactART-test.js @@ -33,16 +33,12 @@ 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; let Surface; let TestComponent; -let waitFor; - const Missing = {}; function testDOMNodeStructure(domNode, expectedStructure) { @@ -80,8 +76,6 @@ describe('ReactART', () => { Shape = ReactART.Shape; Surface = ReactART.Surface; - ({waitFor} = require('internal-test-utils')); - TestComponent = class extends React.Component { group = React.createRef(); @@ -363,58 +357,6 @@ describe('ReactART', () => { doClick(instance); expect(onClick2).toBeCalled(); }); - - // @gate !enableSyncDefaultUpdates - it('can concurrently render with a "primary" renderer while sharing context', async () => { - const CurrentRendererContext = React.createContext(null); - - function Yield(props) { - Scheduler.log(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( - - - - - - , - ); - - await waitFor(['A']); - - ReactDOM.render( - - - - - - , - container, - ); - - expect(ops).toEqual([null, 'ART']); - - ops = []; - await waitFor(['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 3300dc1bb35c3..60c78035e2223 100644 --- a/packages/react-dom/src/__tests__/ReactDOMNativeEventHeuristic-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMNativeEventHeuristic-test.js @@ -312,11 +312,7 @@ describe('ReactDOMNativeEventHeuristic-test', () => { expect(container.textContent).toEqual('not hovered'); await waitFor(['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 ab09c63a7bcb9..498432186e191 100644 --- a/packages/react-dom/src/__tests__/ReactDOMServerPartialHydration-test.internal.js +++ b/packages/react-dom/src/__tests__/ReactDOMServerPartialHydration-test.internal.js @@ -2036,14 +2036,7 @@ describe('ReactDOMServerPartialHydration', () => { suspend = true; await act(async () => { - if (gate(flags => flags.enableSyncDefaultUpdates)) { - await waitFor(['Before', 'After']); - } else { - await waitFor(['Before']); - // This took a long time to render. - Scheduler.unstable_advanceTime(1000); - await waitFor(['After']); - } + await waitFor(['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 4b6c5717fa29b..1a1769e82c07e 100644 --- a/packages/react-dom/src/events/__tests__/DOMPluginEventSystem-test.internal.js +++ b/packages/react-dom/src/events/__tests__/DOMPluginEventSystem-test.internal.js @@ -1984,13 +1984,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 await waitFor(['Test']); diff --git a/packages/react-reconciler/src/ReactFiber.js b/packages/react-reconciler/src/ReactFiber.js index 1e02b09441a2d..f06844533e59a 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__/ReactExpiration-test.js b/packages/react-reconciler/src/__tests__/ReactExpiration-test.js index 2c38a05168a6c..26a82e8be3e38 100644 --- a/packages/react-reconciler/src/__tests__/ReactExpiration-test.js +++ b/packages/react-reconciler/src/__tests__/ReactExpiration-test.js @@ -115,54 +115,29 @@ describe('ReactExpiration', () => { } } - function flushNextRenderIfExpired() { - // This will start rendering the next level of work. If the work hasn't - // expired yet, React will exit without doing anything. If it has expired, - // it will schedule a sync task. - Scheduler.unstable_flushExpired(); - // Flush the sync task. - ReactNoop.flushSync(); - } - it('increases priority of updates as time progresses', async () => { - if (gate(flags => flags.enableSyncDefaultUpdates)) { - ReactNoop.render(); - React.startTransition(() => { - ReactNoop.render(); - }); - await waitFor(['Step 1']); + ReactNoop.render(); + React.startTransition(() => { + ReactNoop.render(); + }); - expect(ReactNoop).toMatchRenderedOutput('Step 1'); + await waitFor(['Step 1']); - // Nothing has expired yet because time hasn't advanced. - await unstable_waitForExpired([]); - expect(ReactNoop).toMatchRenderedOutput('Step 1'); + expect(ReactNoop).toMatchRenderedOutput('Step 1'); - // Advance time a bit, but not enough to expire the low pri update. - ReactNoop.expire(4500); - await unstable_waitForExpired([]); - expect(ReactNoop).toMatchRenderedOutput('Step 1'); + // Nothing has expired yet because time hasn't advanced. + await unstable_waitForExpired([]); + expect(ReactNoop).toMatchRenderedOutput('Step 1'); - // Advance by a little bit more. Now the update should expire and flush. - ReactNoop.expire(500); - await unstable_waitForExpired(['Step 2']); - expect(ReactNoop).toMatchRenderedOutput('Step 2'); - } else { - ReactNoop.render(); - expect(ReactNoop).toMatchRenderedOutput(null); + // Advance time a bit, but not enough to expire the low pri update. + ReactNoop.expire(4500); + await unstable_waitForExpired([]); + expect(ReactNoop).toMatchRenderedOutput('Step 1'); - // Nothing has expired yet because time hasn't advanced. - flushNextRenderIfExpired(); - expect(ReactNoop).toMatchRenderedOutput(null); - // Advance time a bit, but not enough to expire the low pri update. - ReactNoop.expire(4500); - flushNextRenderIfExpired(); - expect(ReactNoop).toMatchRenderedOutput(null); - // Advance by another second. Now the update should expire and flush. - ReactNoop.expire(500); - flushNextRenderIfExpired(); - expect(ReactNoop).toMatchRenderedOutput(); - } + // Advance by a little bit more. Now the update should expire and flush. + ReactNoop.expire(500); + await unstable_waitForExpired(['Step 2']); + expect(ReactNoop).toMatchRenderedOutput('Step 2'); }); it('two updates of like priority in the same event always flush within the same batch', async () => { @@ -187,13 +162,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. @@ -248,13 +219,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. @@ -320,13 +287,9 @@ describe('ReactExpiration', () => { } // Initial mount - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactNoop.render(); - }); - } else { + React.startTransition(() => { ReactNoop.render(); - } + }); await waitForAll([ 'initial [A] [render]', 'initial [B] [render]', @@ -339,13 +302,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'})); - } + }); await waitFor(['1 [A] [render]', '1 [B] [render]']); // Before the update can finish, update again. Even though no time has @@ -371,13 +330,9 @@ describe('ReactExpiration', () => { ); } - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - root.render(); - }); - } else { + React.startTransition(() => { root.render(); - } + }); await waitFor(['A']); await waitFor(['B']); @@ -404,13 +359,9 @@ describe('ReactExpiration', () => { ); } - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - root.render(); - }); - } else { + React.startTransition(() => { root.render(); - } + }); await waitFor(['A']); await waitFor(['B']); @@ -428,62 +379,36 @@ describe('ReactExpiration', () => { jest.resetModules(); Scheduler = require('scheduler'); + const InternalTestUtils = require('internal-test-utils'); + waitFor = InternalTestUtils.waitFor; + assertLog = InternalTestUtils.assertLog; + unstable_waitForExpired = InternalTestUtils.unstable_waitForExpired; - if (gate(flags => flags.enableSyncDefaultUpdates)) { - const InternalTestUtils = require('internal-test-utils'); - waitFor = InternalTestUtils.waitFor; - assertLog = InternalTestUtils.assertLog; - unstable_waitForExpired = InternalTestUtils.unstable_waitForExpired; - - // Before importing the renderer, advance the current time by a number - // larger than the maximum allowed for bitwise operations. - const maxSigned31BitInt = 1073741823; - Scheduler.unstable_advanceTime(maxSigned31BitInt * 100); - - // Now import the renderer. On module initialization, it will read the - // current time. - ReactNoop = require('react-noop-renderer'); - React = require('react'); - - ReactNoop.render(); - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactNoop.render(); - }); - await waitFor(['Step 1']); - } else { - ReactNoop.render('Hi'); - } + // Before importing the renderer, advance the current time by a number + // larger than the maximum allowed for bitwise operations. + const maxSigned31BitInt = 1073741823; + Scheduler.unstable_advanceTime(maxSigned31BitInt * 100); - // The update should not have expired yet. - await unstable_waitForExpired([]); + // Now import the renderer. On module initialization, it will read the + // current time. + ReactNoop = require('react-noop-renderer'); + React = require('react'); - expect(ReactNoop).toMatchRenderedOutput('Step 1'); + ReactNoop.render(); + React.startTransition(() => { + ReactNoop.render(); + }); + await waitFor(['Step 1']); - // Advance the time some more to expire the update. - Scheduler.unstable_advanceTime(10000); - await unstable_waitForExpired(['Step 2']); - expect(ReactNoop).toMatchRenderedOutput('Step 2'); - } else { - // Before importing the renderer, advance the current time by a number - // larger than the maximum allowed for bitwise operations. - const maxSigned31BitInt = 1073741823; - Scheduler.unstable_advanceTime(maxSigned31BitInt * 100); - // Now import the renderer. On module initialization, it will read the - // current time. - ReactNoop = require('react-noop-renderer'); - ReactNoop.render('Hi'); + // The update should not have expired yet. + await unstable_waitForExpired([]); - // The update should not have expired yet. - flushNextRenderIfExpired(); - await waitFor([]); - expect(ReactNoop).toMatchRenderedOutput(null); - // Advance the time some more to expire the update. - Scheduler.unstable_advanceTime(10000); - flushNextRenderIfExpired(); - await waitFor([]); - expect(ReactNoop).toMatchRenderedOutput('Hi'); - } + expect(ReactNoop).toMatchRenderedOutput('Step 1'); + + // Advance the time some more to expire the update. + Scheduler.unstable_advanceTime(10000); + await unstable_waitForExpired(['Step 2']); + expect(ReactNoop).toMatchRenderedOutput('Step 2'); }); it('should measure callback timeout relative to current time, not start-up time', async () => { @@ -494,13 +419,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'); - } + }); await unstable_waitForExpired([]); expect(ReactNoop).toMatchRenderedOutput(null); @@ -541,13 +462,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(); - } + }); await waitFor(['Sync pri: 0']); updateSyncPri(); assertLog(['Sync pri: 1', 'Normal pri: 0']); @@ -565,13 +482,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(); - } + }); await waitFor(['Sync pri: 1']); // This time, a lot of time has elapsed since the normal pri update @@ -732,13 +645,9 @@ describe('ReactExpiration', () => { expect(root).toMatchRenderedOutput('A0BC'); await act(async () => { - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - root.render(); - }); - } else { + React.startTransition(() => { root.render(); - } + }); await waitForAll(['Suspend! [A1]', 'Loading...']); // Lots of time elapses before the promise resolves diff --git a/packages/react-reconciler/src/__tests__/ReactFlushSync-test.js b/packages/react-reconciler/src/__tests__/ReactFlushSync-test.js index 57e2aad2e3334..e2d9ba76660f9 100644 --- a/packages/react-reconciler/src/__tests__/ReactFlushSync-test.js +++ b/packages/react-reconciler/src/__tests__/ReactFlushSync-test.js @@ -49,13 +49,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 await waitForPaint(['0, 0']); diff --git a/packages/react-reconciler/src/__tests__/ReactHooksWithNoopRenderer-test.js b/packages/react-reconciler/src/__tests__/ReactHooksWithNoopRenderer-test.js index 627dc4e856216..c62d12075f7b0 100644 --- a/packages/react-reconciler/src/__tests__/ReactHooksWithNoopRenderer-test.js +++ b/packages/react-reconciler/src/__tests__/ReactHooksWithNoopRenderer-test.js @@ -179,15 +179,10 @@ describe('ReactHooksWithNoopRenderer', () => { // Schedule some updates await act(async () => { - 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 await waitFor(['Count: 11']); @@ -692,24 +687,16 @@ describe('ReactHooksWithNoopRenderer', () => { await waitForAll([0]); expect(root).toMatchRenderedOutput(); - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - root.render(); - }); - } else { + React.startTransition(() => { root.render(); - } + }); await waitForAll(['Suspend!']); expect(root).toMatchRenderedOutput(); // Rendering again should suspend again. - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - root.render(); - }); - } else { + React.startTransition(() => { root.render(); - } + }); await waitForAll(['Suspend!']); }); @@ -755,38 +742,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'); - } + }); await waitForAll(['Suspend!']); expect(root).toMatchRenderedOutput(); // Rendering again should suspend again. - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - root.render(); - }); - } else { + React.startTransition(() => { root.render(); - } + }); await waitForAll(['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(); - } + }); await waitForAll(['B:0']); expect(root).toMatchRenderedOutput(); }); @@ -821,13 +795,9 @@ describe('ReactHooksWithNoopRenderer', () => { ReactNoop.discreteUpdates(() => { setRow(5); }); - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - setRow(20); - }); - } else { + React.startTransition(() => { setRow(20); - } + }); }); assertLog(['Up', 'Down']); expect(root).toMatchRenderedOutput(); @@ -1339,13 +1309,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)); - } + }); await waitFor(['Child one render']); // Schedule unmount for the parent that unmounts children with pending update. @@ -1619,39 +1585,21 @@ describe('ReactHooksWithNoopRenderer', () => { expect(ReactNoop).toMatchRenderedOutput(); // Rendering again should flush the previous commit's effects - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactNoop.render(, () => - Scheduler.log('Sync effect'), - ); - }); - } else { + React.startTransition(() => { ReactNoop.render(, () => Scheduler.log('Sync effect'), ); - } + }); await waitFor(['Schedule update [0]', 'Count: 0']); - if (gate(flags => flags.enableSyncDefaultUpdates)) { - expect(ReactNoop).toMatchRenderedOutput(); - await waitFor([ - 'Count: 0', - 'Sync effect', - 'Schedule update [1]', - 'Count: 1', - ]); - } else { - expect(ReactNoop).toMatchRenderedOutput( - , - ); - await waitFor(['Sync effect']); - expect(ReactNoop).toMatchRenderedOutput(); - - ReactNoop.flushPassiveEffects(); - assertLog(['Schedule update [1]']); - await waitForAll(['Count: 1']); - } + expect(ReactNoop).toMatchRenderedOutput(); + await waitFor([ + '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 4a51c737350d6..fbfaba83ff187 100644 --- a/packages/react-reconciler/src/__tests__/ReactIncremental-test.js +++ b/packages/react-reconciler/src/__tests__/ReactIncremental-test.js @@ -75,13 +75,9 @@ describe('ReactIncremental', () => { return [, ]; } - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactNoop.render(, () => Scheduler.log('callback')); - }); - } else { + React.startTransition(() => { ReactNoop.render(, () => Scheduler.log('callback')); - } + }); // Do one step of work. await waitFor(['Foo']); @@ -168,26 +164,18 @@ describe('ReactIncremental', () => { ReactNoop.render(); await waitForAll(['Foo', 'Bar', 'Bar']); - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactNoop.render(); - }); - } else { + React.startTransition(() => { ReactNoop.render(); - } + }); // Flush part of the work await waitFor(['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 await waitFor(['Foo', 'Bar']); @@ -221,17 +209,7 @@ describe('ReactIncremental', () => { ReactNoop.render(); await waitForAll([]); - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - inst.setState( - () => { - Scheduler.log('setState1'); - return {text: 'bar'}; - }, - () => Scheduler.log('callback1'), - ); - }); - } else { + React.startTransition(() => { inst.setState( () => { Scheduler.log('setState1'); @@ -239,24 +217,14 @@ describe('ReactIncremental', () => { }, () => Scheduler.log('callback1'), ); - } + }); // Flush part of the work await waitFor(['setState1']); // This will abort the previous work and restart ReactNoop.flushSync(() => ReactNoop.render()); - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - inst.setState( - () => { - Scheduler.log('setState2'); - return {text2: 'baz'}; - }, - () => Scheduler.log('callback2'), - ); - }); - } else { + React.startTransition(() => { inst.setState( () => { Scheduler.log('setState2'); @@ -264,7 +232,7 @@ describe('ReactIncremental', () => { }, () => Scheduler.log('callback2'), ); - } + }); // Flush the rest of the work which now includes the low priority await waitForAll(['setState1', 'setState2', 'callback1', 'callback2']); @@ -1825,18 +1793,7 @@ describe('ReactIncremental', () => { 'ShowLocale {"locale":"de"}', 'ShowBoth {"locale":"de"}', ]); - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactNoop.render( - - -
- -
-
, - ); - }); - } else { + React.startTransition(() => { ReactNoop.render( @@ -1845,7 +1802,7 @@ describe('ReactIncremental', () => { , ); - } + }); await waitFor(['Intl {}']); ReactNoop.render( @@ -1977,22 +1934,7 @@ describe('ReactIncremental', () => { } } - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactNoop.render( - - - - - - - - - - , - ); - }); - } else { + React.startTransition(() => { ReactNoop.render( @@ -2005,7 +1947,7 @@ describe('ReactIncremental', () => { , ); - } + }); await waitFor([ 'Intl {}', 'ShowLocale {"locale":"fr"}', @@ -2682,13 +2624,9 @@ describe('ReactIncremental', () => { return null; } - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactNoop.render(); - }); - } else { + React.startTransition(() => { ReactNoop.render(); - } + }); await waitFor(['Parent: 1']); // Interrupt at same priority @@ -2708,13 +2646,9 @@ describe('ReactIncremental', () => { return null; } - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactNoop.render(); - }); - } else { + React.startTransition(() => { ReactNoop.render(); - } + }); await waitFor(['Parent: 1']); // Interrupt at lower priority @@ -2735,13 +2669,9 @@ describe('ReactIncremental', () => { return null; } - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactNoop.render(); - }); - } else { + React.startTransition(() => { ReactNoop.render(); - } + }); await waitFor(['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 ac606f1e6870a..2f6b225f2f60e 100644 --- a/packages/react-reconciler/src/__tests__/ReactIncrementalErrorHandling-test.internal.js +++ b/packages/react-reconciler/src/__tests__/ReactIncrementalErrorHandling-test.internal.js @@ -97,25 +97,7 @@ describe('ReactIncrementalErrorHandling', () => { throw new Error('oops!'); } - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactNoop.render( - <> - - - - - - - - - - - - , - ); - }); - } else { + React.startTransition(() => { ReactNoop.render( <> @@ -131,7 +113,7 @@ describe('ReactIncrementalErrorHandling', () => { , ); - } + }); // Start rendering asynchronously await waitFor([ @@ -214,25 +196,7 @@ describe('ReactIncrementalErrorHandling', () => { throw new Error('oops!'); } - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactNoop.render( - <> - - - - - - - - - - - - , - ); - }); - } else { + React.startTransition(() => { ReactNoop.render( <> @@ -248,7 +212,7 @@ describe('ReactIncrementalErrorHandling', () => { , ); - } + }); // Start rendering asynchronously await waitFor([ @@ -416,13 +380,9 @@ describe('ReactIncrementalErrorHandling', () => { ); } - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactNoop.render(, () => Scheduler.log('commit')); - }); - } else { + React.startTransition(() => { ReactNoop.render(, () => Scheduler.log('commit')); - } + }); // Render the bad component asynchronously await waitFor(['Parent', 'BadRender']); @@ -458,13 +418,9 @@ describe('ReactIncrementalErrorHandling', () => { ); } - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactNoop.render(); - }); - } else { + React.startTransition(() => { ReactNoop.render(); - } + }); // Render part of the tree await waitFor(['A', 'B']); @@ -595,21 +551,13 @@ describe('ReactIncrementalErrorHandling', () => { throw new Error('Hello'); } - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactNoop.render( - - - , - ); - }); - } else { + React.startTransition(() => { ReactNoop.render( , ); - } + }); await waitFor(['ErrorBoundary render success']); expect(ReactNoop).toMatchRenderedOutput(null); @@ -783,21 +731,13 @@ describe('ReactIncrementalErrorHandling', () => { throw new Error('Hello'); } - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactNoop.render( - - - , - ); - }); - } else { + React.startTransition(() => { ReactNoop.render( , ); - } + }); await waitFor(['RethrowErrorBoundary render']); @@ -1856,13 +1796,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. await waitFor(['Oops']); diff --git a/packages/react-reconciler/src/__tests__/ReactIncrementalReflection-test.js b/packages/react-reconciler/src/__tests__/ReactIncrementalReflection-test.js index 2ae5002b97f74..cffd690e64715 100644 --- a/packages/react-reconciler/src/__tests__/ReactIncrementalReflection-test.js +++ b/packages/react-reconciler/src/__tests__/ReactIncrementalReflection-test.js @@ -65,13 +65,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. await waitFor(['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. await waitFor(['Other']); @@ -191,13 +183,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. await waitFor([['componentWillMount', null], 'render', 'render sibling']); @@ -227,13 +215,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(); - } + }); await waitFor([ ['componentWillUpdate', hostSpan], 'render', @@ -254,13 +238,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(); - } + }); await waitFor([ ['componentWillUpdate', hostDiv], 'render', diff --git a/packages/react-reconciler/src/__tests__/ReactIncrementalScheduling-test.js b/packages/react-reconciler/src/__tests__/ReactIncrementalScheduling-test.js index 6a1f16fdc2c7d..8c00ec741206e 100644 --- a/packages/react-reconciler/src/__tests__/ReactIncrementalScheduling-test.js +++ b/packages/react-reconciler/src/__tests__/ReactIncrementalScheduling-test.js @@ -115,15 +115,10 @@ describe('ReactIncrementalScheduling', () => { // Schedule deferred work in the reverse order await act(async () => { - 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 await waitFor(['c:2']); @@ -132,13 +127,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 await waitFor(['b:2']); @@ -189,13 +180,9 @@ describe('ReactIncrementalScheduling', () => { } } - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactNoop.render(); - }); - } else { + React.startTransition(() => { ReactNoop.render(); - } + }); // Render without committing await waitFor(['render: 0']); @@ -209,13 +196,9 @@ describe('ReactIncrementalScheduling', () => { 'componentDidUpdate: 1', ]); - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - instance.setState({tick: 2}); - }); - } else { + React.startTransition(() => { instance.setState({tick: 2}); - } + }); await waitFor(['render: 2']); expect(ReactNoop.flushNextYield()).toEqual([ 'componentDidUpdate: 2', @@ -316,13 +299,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 5df785b7e03cd..b47897e54d92e 100644 --- a/packages/react-reconciler/src/__tests__/ReactIncrementalSideEffects-test.js +++ b/packages/react-reconciler/src/__tests__/ReactIncrementalSideEffects-test.js @@ -464,13 +464,9 @@ describe('ReactIncrementalSideEffects', () => { , ); - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactNoop.render(); - }); - } else { + React.startTransition(() => { ReactNoop.render(); - } + }); // Flush some of the work without committing await waitFor(['Foo', 'Bar']); @@ -703,13 +699,9 @@ describe('ReactIncrementalSideEffects', () => { Scheduler.log('Foo ' + props.step); 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 await waitFor(['Foo 1']); expect(ReactNoop.getChildrenAsJSX()).toEqual(null); @@ -718,26 +710,18 @@ describe('ReactIncrementalSideEffects', () => { await waitForPaint([]); 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 await waitFor(['Foo 2']); 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 13488a7c899de..b224e4d776482 100644 --- a/packages/react-reconciler/src/__tests__/ReactIncrementalUpdates-test.js +++ b/packages/react-reconciler/src/__tests__/ReactIncrementalUpdates-test.js @@ -156,21 +156,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 await waitFor(['a', 'b', 'c']); @@ -187,11 +177,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)) { assertLog(['d', 'e', 'f']); expect(ReactNoop).toMatchRenderedOutput(); } else { @@ -203,11 +189,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)) { await waitForAll([ // Since 'g' is in a transition, we'll process 'd' separately first. // That causes us to process 'd' with 'e' and 'f' rebased. @@ -261,21 +243,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 await waitFor(['a', 'b', 'c']); @@ -295,11 +267,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)) { assertLog(['d', 'e', 'f']); } else { // Update d was dropped and replaced by e. @@ -310,11 +278,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)) { await waitForAll([ // Since 'g' is in a transition, we'll process 'd' separately first. // That causes us to process 'd' with 'e' and 'f' rebased. @@ -543,13 +507,9 @@ describe('ReactIncrementalUpdates', () => { } await act(async () => { - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactNoop.render(); - }); - } else { + React.startTransition(() => { ReactNoop.render(); - } + }); assertLog([]); await waitForAll([ 'Render: 0', @@ -560,13 +520,9 @@ describe('ReactIncrementalUpdates', () => { ]); Scheduler.unstable_advanceTime(10000); - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - setCount(2); - }); - } else { + React.startTransition(() => { setCount(2); - } + }); // The transition should not have expired, so we should be able to // partially render it. await waitFor(['Render: 2']); @@ -583,18 +539,7 @@ describe('ReactIncrementalUpdates', () => { Scheduler.unstable_advanceTime(10000); - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactNoop.render( - <> - - - - - , - ); - }); - } else { + React.startTransition(() => { ReactNoop.render( <> @@ -603,7 +548,7 @@ describe('ReactIncrementalUpdates', () => { , ); - } + }); // The transition should not have expired, so we should be able to // partially render it. await waitFor(['A']); @@ -612,18 +557,7 @@ describe('ReactIncrementalUpdates', () => { }); it('regression: does not expire soon due to previous expired work', async () => { - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactNoop.render( - <> - - - - - , - ); - }); - } else { + React.startTransition(() => { ReactNoop.render( <> @@ -632,8 +566,9 @@ describe('ReactIncrementalUpdates', () => { , ); - } + }); await waitFor(['A']); + // This will expire the rest of the update Scheduler.unstable_advanceTime(10000); await waitFor(['B'], { @@ -643,18 +578,7 @@ describe('ReactIncrementalUpdates', () => { Scheduler.unstable_advanceTime(10000); // Now do another transition. This one should not expire. - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactNoop.render( - <> - - - - - , - ); - }); - } else { + React.startTransition(() => { ReactNoop.render( <> @@ -663,7 +587,7 @@ describe('ReactIncrementalUpdates', () => { , ); - } + }); // The transition should not have expired, so we should be able to // partially render it. await waitFor(['A']); @@ -703,13 +627,9 @@ describe('ReactIncrementalUpdates', () => { expect(root).toMatchRenderedOutput(null); await act(() => { - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - pushToLog('A'); - }); - } else { + React.startTransition(() => { pushToLog('A'); - } + }); ReactNoop.unstable_runWithPriority(ContinuousEventPriority, () => pushToLog('B'), @@ -768,13 +688,9 @@ describe('ReactIncrementalUpdates', () => { expect(root).toMatchRenderedOutput(null); await act(() => { - 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 61e8985ebb0a0..27e8652cb8ac4 100644 --- a/packages/react-reconciler/src/__tests__/ReactInterleavedUpdates-test.js +++ b/packages/react-reconciler/src/__tests__/ReactInterleavedUpdates-test.js @@ -65,78 +65,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. - await waitFor([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. - await waitForPaint([1, 1]); - expect(root).toMatchRenderedOutput('111'); - }); - // The interleaved updates flush in a separate render. - assertLog([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( - <> - - - - , - ); - }); - assertLog([0, 0, 0]); - expect(root).toMatchRenderedOutput('000'); - - await act(async () => { - updateChildren(1); + }); // Partially render the children. Only the first one. await waitFor([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 0ebf8f2d53293..f508ac4abf5b9 100644 --- a/packages/react-reconciler/src/__tests__/ReactLazy-test.internal.js +++ b/packages/react-reconciler/src/__tests__/ReactLazy-test.internal.js @@ -1559,13 +1559,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(); - } + }); await waitForAll(['Init B2', 'Loading...']); await resolveFakeImport(ChildB2); // 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 7f8520088d64f..cedf698148ee1 100644 --- a/packages/react-reconciler/src/__tests__/ReactNewContext-test.js +++ b/packages/react-reconciler/src/__tests__/ReactNewContext-test.js @@ -885,13 +885,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 await waitFor(['Foo']); @@ -934,13 +930,9 @@ describe('ReactNewContext', () => { ); } - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactNoop.render(); - }); - } else { + React.startTransition(() => { ReactNoop.render(); - } + }); await waitForAll(['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 f67e2549862bd..17067638ac811 100644 --- a/packages/react-reconciler/src/__tests__/ReactSchedulerIntegration-test.js +++ b/packages/react-reconciler/src/__tests__/ReactSchedulerIntegration-test.js @@ -109,13 +109,9 @@ describe('ReactSchedulerIntegration', () => { scheduleCallback(NormalPriority, () => Scheduler.log('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'); - } + }); // Perform just a little bit of work. By now, the React task will have // already been scheduled, behind A, B, and C. diff --git a/packages/react-reconciler/src/__tests__/ReactSuspense-test.internal.js b/packages/react-reconciler/src/__tests__/ReactSuspense-test.internal.js index 5723e0039e2eb..df51d2b74d59e 100644 --- a/packages/react-reconciler/src/__tests__/ReactSuspense-test.internal.js +++ b/packages/react-reconciler/src/__tests__/ReactSuspense-test.internal.js @@ -125,13 +125,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(); - } + }); await waitForAll([ 'Foo', @@ -228,19 +224,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( <> }> @@ -250,8 +234,7 @@ describe('ReactSuspense', () => { , ); - } - + }); // Yield past the Suspense boundary but don't complete the last sibling. await waitFor(['Suspend!', 'Loading...', 'After Suspense']); @@ -346,76 +329,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', - async () => { - 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(); - await waitForAll(['A0', 'B0', 'C0']); - expect(root).toMatchRenderedOutput('A0B0C0'); - - // This update will suspend. - root.update(); - - // Do a bit of work - await waitFor(['A1']); - - // Schedule another update. This will have lower priority because it's - // a transition. - React.startTransition(() => { - root.update(); - }); - - // Interrupt to trigger a restart. - interrupt(); - - await waitFor([ - // 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. - await waitForAll(['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__/ReactSuspenseEffectsSemantics-test.js b/packages/react-reconciler/src/__tests__/ReactSuspenseEffectsSemantics-test.js index a684f6ab4d245..defd59acf6423 100644 --- a/packages/react-reconciler/src/__tests__/ReactSuspenseEffectsSemantics-test.js +++ b/packages/react-reconciler/src/__tests__/ReactSuspenseEffectsSemantics-test.js @@ -576,7 +576,7 @@ describe('ReactSuspenseEffectsSemantics', () => { ]); }); - // @gate enableLegacyCache && enableSyncDefaultUpdates + // @gate enableLegacyCache it('should be destroyed and recreated for function components', async () => { function App({children = null}) { Scheduler.log('App render'); @@ -711,7 +711,7 @@ describe('ReactSuspenseEffectsSemantics', () => { ]); }); - // @gate enableLegacyCache && enableSyncDefaultUpdates + // @gate enableLegacyCache it('should be destroyed and recreated for class components', async () => { class ClassText extends React.Component { componentDidMount() { @@ -860,7 +860,7 @@ describe('ReactSuspenseEffectsSemantics', () => { ]); }); - // @gate enableLegacyCache && enableSyncDefaultUpdates + // @gate enableLegacyCache it('should be destroyed and recreated when nested below host components', async () => { function App({children = null}) { Scheduler.log('App render'); @@ -979,7 +979,7 @@ describe('ReactSuspenseEffectsSemantics', () => { ]); }); - // @gate enableLegacyCache && enableSyncDefaultUpdates + // @gate enableLegacyCache it('should be destroyed and recreated even if there is a bailout because of memoization', async () => { const MemoizedText = React.memo(Text, () => true); @@ -1448,7 +1448,7 @@ describe('ReactSuspenseEffectsSemantics', () => { ); }); - // @gate enableLegacyCache && enableSyncDefaultUpdates + // @gate enableLegacyCache it('should be cleaned up inside of a fallback that suspends', async () => { function App({fallbackChildren = null, outerChildren = null}) { return ( @@ -1724,7 +1724,7 @@ describe('ReactSuspenseEffectsSemantics', () => { ); }); - // @gate enableLegacyCache && enableSyncDefaultUpdates + // @gate enableLegacyCache it('should be cleaned up deeper inside of a subtree that suspends', async () => { function ConditionalSuspense({shouldSuspend}) { if (shouldSuspend) { @@ -2305,7 +2305,7 @@ describe('ReactSuspenseEffectsSemantics', () => { }); }); - // @gate enableLegacyCache && enableSyncDefaultUpdates + // @gate enableLegacyCache it('should be only destroy layout effects once if a tree suspends in multiple places', async () => { class ClassText extends React.Component { componentDidMount() { @@ -2448,7 +2448,7 @@ describe('ReactSuspenseEffectsSemantics', () => { ]); }); - // @gate enableLegacyCache && enableSyncDefaultUpdates + // @gate enableLegacyCache it('should be only destroy layout effects once if a component suspends multiple times', async () => { class ClassText 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 2b20ca53d8f91..c3da64090e259 100644 --- a/packages/react-reconciler/src/__tests__/ReactSuspenseList-test.js +++ b/packages/react-reconciler/src/__tests__/ReactSuspenseList-test.js @@ -1366,13 +1366,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(); - } + }); await waitFor(['A']); @@ -1554,13 +1550,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(); - } + }); await waitFor(['A']); @@ -2525,15 +2517,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. await waitFor(['B', 'C']); @@ -2669,14 +2655,9 @@ describe('ReactSuspenseList', () => { ); } - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactNoop.render(); - }); - } else { + React.startTransition(() => { ReactNoop.render(); - } - + }); await waitFor(['App', 'First Pass A', 'Mount A', 'A']); expect(ReactNoop).toMatchRenderedOutput(A); @@ -2737,14 +2718,9 @@ describe('ReactSuspenseList', () => { ); } - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactNoop.render(); - }); - } else { + React.startTransition(() => { ReactNoop.render(); - } - + }); await waitFor([ '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 a901a571a1525..3f1d7444fc49e 100644 --- a/packages/react-reconciler/src/__tests__/ReactSuspenseWithNoopRenderer-test.js +++ b/packages/react-reconciler/src/__tests__/ReactSuspenseWithNoopRenderer-test.js @@ -285,13 +285,9 @@ describe('ReactSuspenseWithNoopRenderer', () => { await waitForAll(['Foo']); // The update will suspend. - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactNoop.render(); - }); - } else { + React.startTransition(() => { ReactNoop.render(); - } + }); await waitForAll([ 'Foo', 'Bar', @@ -369,18 +365,7 @@ describe('ReactSuspenseWithNoopRenderer', () => { // A shell is needed. The update cause it to suspend. ReactNoop.render(} />); await waitForAll([]); - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactNoop.render( - }> - - - - - , - ); - }); - } else { + React.startTransition(() => { ReactNoop.render( }> @@ -389,7 +374,7 @@ describe('ReactSuspenseWithNoopRenderer', () => { , ); - } + }); // B suspends. Render a fallback await waitForAll(['A', 'Suspend! [B]', 'Loading...']); // Did not commit yet. @@ -447,13 +432,9 @@ describe('ReactSuspenseWithNoopRenderer', () => { await waitForAll([]); expect(ReactNoop).toMatchRenderedOutput(null); - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactNoop.render(); - }); - } else { + React.startTransition(() => { ReactNoop.render(); - } + }); await waitForAll(['Suspend! [Result]', 'Loading...']); expect(ReactNoop).toMatchRenderedOutput(null); @@ -613,26 +594,18 @@ describe('ReactSuspenseWithNoopRenderer', () => { await waitForAll([]); expect(ReactNoop).toMatchRenderedOutput(null); - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactNoop.render(); - }); - } else { + React.startTransition(() => { ReactNoop.render(); - } + }); await waitForAll(['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(); - } + }); await waitForAll(['Suspend! [A]', 'Loading...']); expect(ReactNoop).toMatchRenderedOutput(null); @@ -714,35 +687,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); await waitFor(['Sibling']); interrupt(); - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - root.render(); - }); - } else { + React.startTransition(() => { root.render(); - } + }); Scheduler.unstable_advanceTime(1000); await waitFor(['Sibling']); interrupt(); - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - root.render(); - }); - } else { + React.startTransition(() => { root.render(); - } + }); Scheduler.unstable_advanceTime(1000); await waitFor(['Sibling']); interrupt(); @@ -1056,18 +1017,7 @@ describe('ReactSuspenseWithNoopRenderer', () => { ); await waitForAll([]); expect(root).toMatchRenderedOutput(null); - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - root.render( - <> - }> - - - - , - ); - }); - } else { + React.startTransition(() => { root.render( <> }> @@ -1076,7 +1026,7 @@ describe('ReactSuspenseWithNoopRenderer', () => { , ); - } + }); await waitFor(['Suspend! [Async]']); await resolveText('Async'); @@ -1139,21 +1089,13 @@ describe('ReactSuspenseWithNoopRenderer', () => { ReactNoop.render(} />); await waitForAll([]); - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactNoop.render( - }> - - , - ); - }); - } else { + React.startTransition(() => { ReactNoop.render( }> , ); - } + }); await waitForAll(['Suspend! [Async]', 'Loading...']); expect(ReactNoop).toMatchRenderedOutput(null); @@ -1934,13 +1876,9 @@ describe('ReactSuspenseWithNoopRenderer', () => { ReactNoop.render(); await waitForAll(['Foo']); - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactNoop.render(); - }); - } else { + React.startTransition(() => { ReactNoop.render(); - } + }); Scheduler.unstable_advanceTime(100); await advanceTimers(100); // Start rendering @@ -1969,22 +1907,14 @@ describe('ReactSuspenseWithNoopRenderer', () => { await advanceTimers(500); // No need to rerender. await waitForAll([]); - 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'); + await waitForAll(['Foo', 'A']); // Renders successfully - if (gate(flags => flags.enableSyncDefaultUpdates)) { - // TODO: Why does this render Foo - await waitForAll(['Foo', 'A']); - } else { - await waitForAll(['A']); - } + // TODO: Why does this render Foo expect(ReactNoop).toMatchRenderedOutput(); }); @@ -2130,13 +2060,9 @@ describe('ReactSuspenseWithNoopRenderer', () => { ReactNoop.render(); await waitForAll(['Foo']); - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactNoop.render(); - }); - } else { + React.startTransition(() => { ReactNoop.render(); - } + }); await waitFor(['Foo']); // Advance some time. @@ -2161,12 +2087,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. await waitForAll([]); - 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. @@ -2518,13 +2440,9 @@ describe('ReactSuspenseWithNoopRenderer', () => { await waitForAll(['Foo', 'A']); expect(ReactNoop).toMatchRenderedOutput(); - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactNoop.render(); - }); - } else { + React.startTransition(() => { ReactNoop.render(); - } + }); await waitForAll(['Foo', 'A', 'Suspend! [B]', 'Loading B...']); // Still suspended. @@ -2534,17 +2452,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 @@ -2569,13 +2478,9 @@ describe('ReactSuspenseWithNoopRenderer', () => { await waitForAll(['Foo', 'A']); expect(ReactNoop).toMatchRenderedOutput(); - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactNoop.render(); - }); - } else { + React.startTransition(() => { ReactNoop.render(); - } + }); await waitForAll([ 'Foo', @@ -2590,12 +2495,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 @@ -3131,26 +3032,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(); - } + }); await waitForAll(['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(); - } + }); await waitForAll(['Suspend! [Second update]']); // Should not display a fallback @@ -3914,117 +3807,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 startTransitionFromB; - function B() { - const [textB, _setTextB] = useState('B'); - // eslint-disable-next-line no-unused-vars - const [_, _startTransition] = useTransition(); - startTransitionFromB = _startTransition; - setTextB = _setTextB; - return ( - }> - - - ); - } - - function App() { - return ( - <> - - - - ); - } - - const root = ReactNoop.createRoot(); - await act(async () => { - await seedNextTextCache('A'); - await seedNextTextCache('B'); - root.render(); - }); - assertLog(['A', 'B']); - expect(root).toMatchRenderedOutput( - <> - - - , - ); - - await act(async () => { - // Triggers suspense at normal pri - setTextA('A1'); - // Triggers in an unrelated tree at a different pri - startTransitionFromB(() => { - // 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'); - }); - - await waitFor([ - 'B', - 'Suspend! [A1]', - 'Loading...', - - 'Suspend! [A2]', - 'Loading...', - 'Suspend! [B2]', - 'Loading...', - ]); - expect(root).toMatchRenderedOutput( - <> - - - , - ); - - await resolveText('A1'); - await waitFor([ - 'A1', - 'Suspend! [A2]', - 'Loading...', - 'Suspend! [B2]', - 'Loading...', - ]); - expect(root).toMatchRenderedOutput( - <> - - - , - ); - - await resolveText('A2'); - await resolveText('B2'); - }); - assertLog(['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 4ae03ac8250ca..9c7365f6216d9 100644 --- a/packages/react-reconciler/src/__tests__/useMutableSource-test.internal.js +++ b/packages/react-reconciler/src/__tests__/useMutableSource-test.internal.js @@ -221,27 +221,7 @@ describe('useMutableSource', () => { const mutableSource = createMutableSource(source, param => param.version); await act(async () => { - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactNoop.render( - <> - - - , - () => Scheduler.log('Sync effect'), - ); - }); - } else { + React.startTransition(() => { ReactNoop.render( <> { , () => Scheduler.log('Sync effect'), ); - } + }); // Do enough work to read from one component await waitFor(['a:one']); @@ -456,13 +436,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'; - } + }); await waitFor(['a:two']); // Re-renders that occur before the update is processed @@ -720,33 +696,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.log('Sync effect'), - ); - }); - } else { + React.startTransition(() => { ReactNoop.render( <> { , () => Scheduler.log('Sync effect'), ); - } + }); await waitFor(['a:a:one', 'b:b:one']); // Mutating the source should trigger a tear detection on the next read, @@ -856,26 +806,7 @@ describe('useMutableSource', () => { await act(async () => { // Start a render that uses the mutable source. - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactNoop.render( - <> - - - , - ); - }); - } else { + React.startTransition(() => { ReactNoop.render( <> { /> , ); - } + }); await waitFor(['a:one']); // Mutate source @@ -1524,17 +1455,7 @@ describe('useMutableSource', () => { expect(root).toMatchRenderedOutput('a0'); await act(async () => { - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - root.render( - <> - - - - , - ); - }); - } else { + React.startTransition(() => { root.render( <> @@ -1542,7 +1463,7 @@ describe('useMutableSource', () => { , ); - } + }); await waitFor(['a0', 'b0']); // Mutate in an event. This schedules a subscription update on a, which @@ -1676,13 +1597,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 await waitFor(['Parent: 2']); @@ -1693,41 +1610,19 @@ describe('useMutableSource', () => { source.valueB = '3'; }); - if (gate(flags => flags.enableSyncDefaultUpdates)) { - // In default sync mode, all of the updates flush sync. - await waitFor([ - // The partial render completes - 'Child: 2', - 'Commit: 2, 2', - 'Parent: 3', - 'Child: 3', - ]); - - await waitForAll([ - // Now finish the rest of the update - 'Commit: 3, 3', - ]); - } else { - await waitFor([ - // 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. - // - await waitFor([ - 'Parent: 3', - // Demonstrates that we can yield here - ]); - await waitFor([ - // Now finish the rest of the update - 'Child: 3', - 'Commit: 3, 3', - ]); - } + // In default sync mode, all of the updates flush sync. + await waitFor([ + // The partial render completes + 'Child: 2', + 'Commit: 2, 2', + 'Parent: 3', + 'Child: 3', + ]); + + await waitForAll([ + // Now finish the rest of the update + 'Commit: 3, 3', + ]); }); }); @@ -1843,26 +1738,7 @@ describe('useMutableSource', () => { await act(async () => { // Start a render that uses the mutable source. - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactNoop.render( - <> - - - , - ); - }); - } else { + React.startTransition(() => { ReactNoop.render( <> { /> , ); - } + }); await waitFor(['a:one']); const PrevScheduler = Scheduler; @@ -1924,26 +1800,7 @@ describe('useMutableSource', () => { await act(async () => { // Start a render that uses the mutable source. - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactNoop.render( - <> - - - , - ); - }); - } else { + React.startTransition(() => { ReactNoop.render( <> { /> , ); - } + }); await waitFor(['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 87a9d2ea4fb5f..f8f77a27f141e 100644 --- a/packages/react-reconciler/src/__tests__/useMutableSourceHydration-test.js +++ b/packages/react-reconciler/src/__tests__/useMutableSourceHydration-test.js @@ -260,23 +260,14 @@ describe('useMutableSourceHydration', () => { await expect(async () => { await act(async () => { - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactDOMClient.hydrateRoot(container, , { - mutableSources: [mutableSource], - onRecoverableError(error) { - Scheduler.log('Log error: ' + error.message); - }, - }); - }); - } else { + React.startTransition(() => { ReactDOMClient.hydrateRoot(container, , { mutableSources: [mutableSource], onRecoverableError(error) { Scheduler.log('Log error: ' + error.message); }, }); - } + }); await waitFor(['a:one']); source.value = 'two'; }); diff --git a/packages/react-test-renderer/src/__tests__/ReactTestRendererAsync-test.js b/packages/react-test-renderer/src/__tests__/ReactTestRendererAsync-test.js index 3e29b28500003..468f62d39a722 100644 --- a/packages/react-test-renderer/src/__tests__/ReactTestRendererAsync-test.js +++ b/packages/react-test-renderer/src/__tests__/ReactTestRendererAsync-test.js @@ -95,17 +95,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 await waitFor(['A:1', 'B:1']); @@ -141,17 +135,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 await waitFor(['A:1']); diff --git a/packages/react/src/__tests__/ReactProfiler-test.internal.js b/packages/react/src/__tests__/ReactProfiler-test.internal.js index 9ae071f360617..de6b7f973e66b 100644 --- a/packages/react/src/__tests__/ReactProfiler-test.internal.js +++ b/packages/react/src/__tests__/ReactProfiler-test.internal.js @@ -206,19 +206,7 @@ describe(`onRender`, () => { return null; }; - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - ReactTestRenderer.create( - - - - , - { - unstable_isConcurrent: true, - }, - ); - }); - } else { + React.startTransition(() => { ReactTestRenderer.create( @@ -228,7 +216,7 @@ describe(`onRender`, () => { unstable_isConcurrent: true, }, ); - } + }); // Times are logged until a render is committed. await waitFor(['first']); @@ -763,17 +751,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( @@ -781,7 +759,7 @@ describe(`onRender`, () => { , {unstable_isConcurrent: true}, ); - } + }); await waitFor(['Yield:2']); expect(callback).toHaveBeenCalledTimes(0); @@ -810,20 +788,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( @@ -834,7 +799,7 @@ describe(`onRender`, () => { , {unstable_isConcurrent: true}, ); - } + }); await waitFor(['Yield:5']); expect(callback).toHaveBeenCalledTimes(0); @@ -876,17 +841,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( @@ -894,7 +849,7 @@ describe(`onRender`, () => { , {unstable_isConcurrent: true}, ); - } + }); await waitFor(['Yield:10']); expect(callback).toHaveBeenCalledTimes(0); @@ -963,17 +918,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( @@ -981,7 +926,7 @@ describe(`onRender`, () => { , ); - } + }); await waitFor(['Yield:3']); expect(callback).toHaveBeenCalledTimes(0); @@ -1083,13 +1028,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}); - } + }); await waitFor(['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 218cd3a2daabb..d28e2ad8de64a 100644 --- a/packages/react/src/__tests__/ReactProfilerDevToolsIntegration-test.internal.js +++ b/packages/react/src/__tests__/ReactProfilerDevToolsIntegration-test.internal.js @@ -161,13 +161,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. await waitFor([]); diff --git a/packages/shared/ReactFeatureFlags.js b/packages/shared/ReactFeatureFlags.js index f3250c17fa335..619b4bf152a9b 100644 --- a/packages/shared/ReactFeatureFlags.js +++ b/packages/shared/ReactFeatureFlags.js @@ -142,9 +142,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 456d78a191e25..3b54b4d9d60d1 100644 --- a/packages/shared/forks/ReactFeatureFlags.native-fb.js +++ b/packages/shared/forks/ReactFeatureFlags.native-fb.js @@ -64,7 +64,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 29d464cb8833c..0efdd6e8b18c1 100644 --- a/packages/shared/forks/ReactFeatureFlags.native-oss.js +++ b/packages/shared/forks/ReactFeatureFlags.native-oss.js @@ -54,7 +54,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 f102289afedde..f4d7962376d46 100644 --- a/packages/shared/forks/ReactFeatureFlags.test-renderer.js +++ b/packages/shared/forks/ReactFeatureFlags.test-renderer.js @@ -54,7 +54,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 e1d66519d50e2..4dbf373f8c182 100644 --- a/packages/shared/forks/ReactFeatureFlags.test-renderer.native.js +++ b/packages/shared/forks/ReactFeatureFlags.test-renderer.native.js @@ -53,7 +53,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 8e7343adb750d..a193740fb0ab7 100644 --- a/packages/shared/forks/ReactFeatureFlags.test-renderer.www.js +++ b/packages/shared/forks/ReactFeatureFlags.test-renderer.www.js @@ -54,7 +54,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.www-dynamic.js b/packages/shared/forks/ReactFeatureFlags.www-dynamic.js index 0926f66fc3a80..69c5fad8938a6 100644 --- a/packages/shared/forks/ReactFeatureFlags.www-dynamic.js +++ b/packages/shared/forks/ReactFeatureFlags.www-dynamic.js @@ -20,7 +20,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 enableTransitionTracing = __VARIANT__; export const enableCustomElementPropertySupport = __VARIANT__; diff --git a/packages/shared/forks/ReactFeatureFlags.www.js b/packages/shared/forks/ReactFeatureFlags.www.js index f0157f00f777d..229b60c37f155 100644 --- a/packages/shared/forks/ReactFeatureFlags.www.js +++ b/packages/shared/forks/ReactFeatureFlags.www.js @@ -24,7 +24,6 @@ export const { enableDebugTracing, enableUseRefAccessWarning, enableLazyContextPropagation, - enableSyncDefaultUpdates, enableUnifiedSyncLane, enableTransitionTracing, enableCustomElementPropertySupport, diff --git a/packages/use-subscription/src/__tests__/useSubscription-test.js b/packages/use-subscription/src/__tests__/useSubscription-test.js index f3d8d3905320a..19eba0a15be8e 100644 --- a/packages/use-subscription/src/__tests__/useSubscription-test.js +++ b/packages/use-subscription/src/__tests__/useSubscription-test.js @@ -339,13 +339,9 @@ describe('useSubscription', () => { // Start React update, but don't finish await act(async () => { - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - renderer.update(); - }); - } else { + React.startTransition(() => { renderer.update(); - } + }); await waitFor(['Child: b-0']); expect(log).toEqual(['Parent.componentDidMount']); @@ -447,13 +443,9 @@ describe('useSubscription', () => { // Start React update, but don't finish await act(async () => { - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - renderer.update(); - }); - } else { + React.startTransition(() => { renderer.update(); - } + }); await waitFor(['Child: b-0']); expect(log).toEqual([]); @@ -632,21 +624,13 @@ 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'); - } + }); await waitFor(['render:first:C', 'render:second:C']); - if (gate(flags => flags.enableSyncDefaultUpdates)) { - React.startTransition(() => { - mutate('D'); - }); - } else { + React.startTransition(() => { mutate('D'); - } + }); await waitForAll(['render:first:D', 'render:second:D']); // No more pending updates