Cleanup enableSyncDefaultUpdate flag (#26236)
This feature flag is enabled everywhere.
Jan Kassens committed
Feb 27, 2023 at 14:04 UTC
b2ae9ddb3b497d16a7c27c051da1827d08871138
38 files changed
+271
-1382
packages/react-art/src/__tests__/ReactART-test.js
-54
@@ -33,8 +33,6 @@ const ReactTestRenderer = require('react-test-renderer');
33
34
// Isolate the noop renderer
35
jest.resetModules();
36
-const ReactNoop = require('react-noop-renderer');
37
-const Scheduler = require('scheduler');
36
37
let Group;
38
let Shape;
@@ -359,58 +357,6 @@ describe('ReactART', () => {
357
doClick(instance);
358
expect(onClick2).toBeCalled();
359
});
362
-
363
- // @gate !enableSyncDefaultUpdates
364
- it('can concurrently render with a "primary" renderer while sharing context', () => {
365
- const CurrentRendererContext = React.createContext(null);
366
-
367
- function Yield(props) {
368
- Scheduler.unstable_yieldValue(props.value);
369
- return null;
370
- }
371
-
372
- let ops = [];
373
- function LogCurrentRenderer() {
374
- return (
375
- <CurrentRendererContext.Consumer>
376
- {currentRenderer => {
377
- ops.push(currentRenderer);
378
- return null;
379
- }}
380
- </CurrentRendererContext.Consumer>
381
- );
382
- }
383
-
384
- // Using test renderer instead of the DOM renderer here because async
385
- // testing APIs for the DOM renderer don't exist.
386
- ReactNoop.render(
387
- <CurrentRendererContext.Provider value="Test">
388
- <Yield value="A" />
389
- <Yield value="B" />
390
- <LogCurrentRenderer />
391
- <Yield value="C" />
392
- </CurrentRendererContext.Provider>,
393
- );
394
-
395
- expect(Scheduler).toFlushAndYieldThrough(['A']);
396
-
397
- ReactDOM.render(
398
- <Surface>
399
- <LogCurrentRenderer />
400
- <CurrentRendererContext.Provider value="ART">
401
- <LogCurrentRenderer />
402
- </CurrentRendererContext.Provider>
403
- </Surface>,
404
- container,
405
- );
406
-
407
- expect(ops).toEqual([null, 'ART']);
408
-
409
- ops = [];
410
- expect(Scheduler).toFlushAndYield(['B', 'C']);
411
-
412
- expect(ops).toEqual(['Test']);
413
- });
360
});
361
362
describe('ReactARTComponents', () => {
packages/react-dom/src/__tests__/ReactDOMNativeEventHeuristic-test.js
+1
-5
@@ -305,11 +305,7 @@ describe('ReactDOMNativeEventHeuristic-test', () => {
305
expect(container.textContent).toEqual('not hovered');
306
307
expect(Scheduler).toFlushAndYieldThrough(['hovered']);
308
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
309
- expect(container.textContent).toEqual('hovered');
310
- } else {
311
- expect(container.textContent).toEqual('not hovered');
312
- }
308
+ expect(container.textContent).toEqual('hovered');
309
});
310
expect(container.textContent).toEqual('hovered');
311
});
packages/react-dom/src/__tests__/ReactDOMServerPartialHydration-test.internal.js
+1
-8
@@ -2044,14 +2044,7 @@ describe('ReactDOMServerPartialHydration', () => {
2044
suspend = true;
2045
2046
await act(async () => {
2047
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
2048
- expect(Scheduler).toFlushAndYieldThrough(['Before', 'After']);
2049
- } else {
2050
- expect(Scheduler).toFlushAndYieldThrough(['Before']);
2051
- // This took a long time to render.
2052
- Scheduler.unstable_advanceTime(1000);
2053
- expect(Scheduler).toFlushAndYield(['After']);
2054
- }
2047
+ expect(Scheduler).toFlushAndYieldThrough(['Before', 'After']);
2048
2049
// This will cause us to skip the second row completely.
2050
});
packages/react-dom/src/events/__tests__/DOMPluginEventSystem-test.internal.js
+2
-6
@@ -1965,13 +1965,9 @@ describe('DOMPluginEventSystem', () => {
1965
log.length = 0;
1966
1967
// Increase counter
1968
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
1969
- React.startTransition(() => {
1970
- root.render(<Test counter={1} />);
1971
- });
1972
- } else {
1968
+ React.startTransition(() => {
1969
root.render(<Test counter={1} />);
1974
- }
1970
+ });
1971
// Yield before committing
1972
expect(Scheduler).toFlushAndYieldThrough(['Test']);
1973
packages/react-reconciler/src/ReactFiber.js
+2
-5
@@ -33,7 +33,6 @@ import {
33
enableProfilerTimer,
34
enableScopeAPI,
35
enableLegacyHidden,
36
- enableSyncDefaultUpdates,
36
allowConcurrentByDefault,
37
enableTransitionTracing,
38
enableDebugTracing,
@@ -459,11 +458,9 @@ export function createHostRootFiber(
458
mode |= StrictLegacyMode | StrictEffectsMode;
459
}
460
if (
462
- // We only use this flag for our repo tests to check both behaviors.
463
- // TODO: Flip this flag and rename it something like "forceConcurrentByDefaultForTesting"
464
- !enableSyncDefaultUpdates ||
461
// Only for internal experiments.
466
- (allowConcurrentByDefault && concurrentUpdatesByDefaultOverride)
462
+ allowConcurrentByDefault &&
463
+ concurrentUpdatesByDefaultOverride
464
) {
465
mode |= ConcurrentUpdatesByDefaultMode;
466
}
packages/react-reconciler/src/__tests__/ReactDisableSchedulerTimeoutBasedOnReactExpirationTime-test.internal.js
+2
-6
@@ -63,13 +63,9 @@ describe('ReactSuspenseList', () => {
63
root.render(<App show={false} />);
64
expect(Scheduler).toFlushAndYield([]);
65
66
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
67
- React.startTransition(() => {
68
- root.render(<App show={true} />);
69
- });
70
- } else {
66
+ React.startTransition(() => {
67
root.render(<App show={true} />);
72
- }
68
+ });
69
expect(Scheduler).toFlushAndYield([
70
'Suspend! [A]',
71
'Suspend! [B]',
packages/react-reconciler/src/__tests__/ReactExpiration-test.js
+24
-72
@@ -115,13 +115,9 @@ describe('ReactExpiration', () => {
115
}
116
117
it('increases priority of updates as time progresses', () => {
118
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
119
- React.startTransition(() => {
120
- ReactNoop.render(<span prop="done" />);
121
- });
122
- } else {
118
+ React.startTransition(() => {
119
ReactNoop.render(<span prop="done" />);
124
- }
120
+ });
121
122
expect(ReactNoop).toMatchRenderedOutput(null);
123
@@ -162,13 +158,9 @@ describe('ReactExpiration', () => {
158
159
// First, show what happens for updates in two separate events.
160
// Schedule an update.
165
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
166
- React.startTransition(() => {
167
- ReactNoop.render(<TextClass text="A" />);
168
- });
169
- } else {
161
+ React.startTransition(() => {
162
ReactNoop.render(<TextClass text="A" />);
171
- }
163
+ });
164
// Advance the timer.
165
Scheduler.unstable_advanceTime(2000);
166
// Partially flush the first update, then interrupt it.
@@ -223,13 +215,9 @@ describe('ReactExpiration', () => {
215
216
// First, show what happens for updates in two separate events.
217
// Schedule an update.
226
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
227
- React.startTransition(() => {
228
- ReactNoop.render(<TextClass text="A" />);
229
- });
230
- } else {
218
+ React.startTransition(() => {
219
ReactNoop.render(<TextClass text="A" />);
232
- }
220
+ });
221
// Advance the timer.
222
Scheduler.unstable_advanceTime(2000);
223
// Partially flush the first update, then interrupt it.
@@ -301,13 +289,9 @@ describe('ReactExpiration', () => {
289
}
290
291
// Initial mount
304
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
305
- React.startTransition(() => {
306
- ReactNoop.render(<App />);
307
- });
308
- } else {
292
+ React.startTransition(() => {
293
ReactNoop.render(<App />);
310
- }
294
+ });
295
expect(Scheduler).toFlushAndYield([
296
'initial [A] [render]',
297
'initial [B] [render]',
@@ -320,13 +304,9 @@ describe('ReactExpiration', () => {
304
]);
305
306
// Partial update
323
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
324
- React.startTransition(() => {
325
- subscribers.forEach(s => s.setState({text: '1'}));
326
- });
327
- } else {
307
+ React.startTransition(() => {
308
subscribers.forEach(s => s.setState({text: '1'}));
329
- }
309
+ });
310
expect(Scheduler).toFlushAndYieldThrough([
311
'1 [A] [render]',
312
'1 [B] [render]',
@@ -358,13 +338,9 @@ describe('ReactExpiration', () => {
338
);
339
}
340
361
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
362
- React.startTransition(() => {
363
- root.render(<App />);
364
- });
365
- } else {
341
+ React.startTransition(() => {
342
root.render(<App />);
367
- }
343
+ });
344
345
expect(Scheduler).toFlushAndYieldThrough(['A']);
346
expect(Scheduler).toFlushAndYieldThrough(['B']);
@@ -392,13 +368,9 @@ describe('ReactExpiration', () => {
368
</>
369
);
370
}
395
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
396
- React.startTransition(() => {
397
- root.render(<App />);
398
- });
399
- } else {
371
+ React.startTransition(() => {
372
root.render(<App />);
401
- }
373
+ });
374
375
expect(Scheduler).toFlushAndYieldThrough(['A']);
376
expect(Scheduler).toFlushAndYieldThrough(['B']);
@@ -426,13 +398,9 @@ describe('ReactExpiration', () => {
398
// current time.
399
ReactNoop = require('react-noop-renderer');
400
429
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
430
- React.startTransition(() => {
431
- ReactNoop.render('Hi');
432
- });
433
- } else {
401
+ React.startTransition(() => {
402
ReactNoop.render('Hi');
435
- }
403
+ });
404
405
// The update should not have expired yet.
406
flushNextRenderIfExpired();
@@ -455,13 +423,9 @@ describe('ReactExpiration', () => {
423
// Before scheduling an update, advance the current time.
424
Scheduler.unstable_advanceTime(10000);
425
458
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
459
- React.startTransition(() => {
460
- ReactNoop.render('Hi');
461
- });
462
- } else {
426
+ React.startTransition(() => {
427
ReactNoop.render('Hi');
464
- }
428
+ });
429
flushNextRenderIfExpired();
430
expect(Scheduler).toHaveYielded([]);
431
expect(ReactNoop).toMatchRenderedOutput(null);
@@ -504,13 +468,9 @@ describe('ReactExpiration', () => {
468
469
// First demonstrate what happens when there's no starvation
470
await act(async () => {
507
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
508
- React.startTransition(() => {
509
- updateNormalPri();
510
- });
511
- } else {
471
+ React.startTransition(() => {
472
updateNormalPri();
513
- }
473
+ });
474
expect(Scheduler).toFlushAndYieldThrough(['Sync pri: 0']);
475
updateSyncPri();
476
expect(Scheduler).toHaveYielded(['Sync pri: 1', 'Normal pri: 0']);
@@ -528,13 +488,9 @@ describe('ReactExpiration', () => {
488
489
// Do the same thing, but starve the first update
490
await act(async () => {
531
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
532
- React.startTransition(() => {
533
- updateNormalPri();
534
- });
535
- } else {
491
+ React.startTransition(() => {
492
updateNormalPri();
537
- }
493
+ });
494
expect(Scheduler).toFlushAndYieldThrough(['Sync pri: 1']);
495
496
// This time, a lot of time has elapsed since the normal pri update
@@ -690,13 +646,9 @@ describe('ReactExpiration', () => {
646
expect(root).toMatchRenderedOutput('A0BC');
647
648
await act(async () => {
693
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
694
- React.startTransition(() => {
695
- root.render(<App step={1} />);
696
- });
697
- } else {
649
+ React.startTransition(() => {
650
root.render(<App step={1} />);
699
- }
651
+ });
652
expect(Scheduler).toFlushAndYield([
653
'Suspend! [A1]',
654
'B',
packages/react-reconciler/src/__tests__/ReactFlushSync-test.js
+2
-6
@@ -41,13 +41,9 @@ describe('ReactFlushSync', () => {
41
42
const root = ReactNoop.createRoot();
43
await act(async () => {
44
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
45
- React.startTransition(() => {
46
- root.render(<App />);
47
- });
48
- } else {
44
+ React.startTransition(() => {
45
root.render(<App />);
50
- }
46
+ });
47
// This will yield right before the passive effect fires
48
expect(Scheduler).toFlushUntilNextPaint(['0, 0']);
49
packages/react-reconciler/src/__tests__/ReactHooksWithNoopRenderer-test.js
+25
-77
@@ -167,15 +167,10 @@ describe('ReactHooksWithNoopRenderer', () => {
167
168
// Schedule some updates
169
act(() => {
170
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
171
- React.startTransition(() => {
172
- counter.current.updateCount(1);
173
- counter.current.updateCount(count => count + 10);
174
- });
175
- } else {
170
+ React.startTransition(() => {
171
counter.current.updateCount(1);
172
counter.current.updateCount(count => count + 10);
178
- }
173
+ });
174
175
// Partially flush without committing
176
expect(Scheduler).toFlushAndYieldThrough(['Count: 11']);
@@ -694,24 +689,16 @@ describe('ReactHooksWithNoopRenderer', () => {
689
expect(Scheduler).toFlushAndYield([0]);
690
expect(root).toMatchRenderedOutput(<span prop={0} />);
691
697
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
698
- React.startTransition(() => {
699
- root.render(<Foo signal={false} />);
700
- });
701
- } else {
692
+ React.startTransition(() => {
693
root.render(<Foo signal={false} />);
703
- }
694
+ });
695
expect(Scheduler).toFlushAndYield(['Suspend!']);
696
expect(root).toMatchRenderedOutput(<span prop={0} />);
697
698
// Rendering again should suspend again.
708
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
709
- React.startTransition(() => {
710
- root.render(<Foo signal={false} />);
711
- });
712
- } else {
699
+ React.startTransition(() => {
700
root.render(<Foo signal={false} />);
714
- }
701
+ });
702
expect(Scheduler).toFlushAndYield(['Suspend!']);
703
});
704
@@ -757,38 +744,25 @@ describe('ReactHooksWithNoopRenderer', () => {
744
expect(root).toMatchRenderedOutput(<span prop="A:0" />);
745
746
await act(async () => {
760
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
761
- React.startTransition(() => {
762
- root.render(<Foo signal={false} />);
763
- setLabel('B');
764
- });
765
- } else {
747
+ React.startTransition(() => {
748
root.render(<Foo signal={false} />);
749
setLabel('B');
768
- }
750
+ });
751
752
expect(Scheduler).toFlushAndYield(['Suspend!']);
753
expect(root).toMatchRenderedOutput(<span prop="A:0" />);
754
755
// Rendering again should suspend again.
774
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
775
- React.startTransition(() => {
776
- root.render(<Foo signal={false} />);
777
- });
778
- } else {
756
+ React.startTransition(() => {
757
root.render(<Foo signal={false} />);
780
- }
758
+ });
759
expect(Scheduler).toFlushAndYield(['Suspend!']);
760
761
// Flip the signal back to "cancel" the update. However, the update to
762
// label should still proceed. It shouldn't have been dropped.
785
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
786
- React.startTransition(() => {
787
- root.render(<Foo signal={true} />);
788
- });
789
- } else {
763
+ React.startTransition(() => {
764
root.render(<Foo signal={true} />);
791
- }
765
+ });
766
expect(Scheduler).toFlushAndYield(['B:0']);
767
expect(root).toMatchRenderedOutput(<span prop="B:0" />);
768
});
@@ -823,13 +797,9 @@ describe('ReactHooksWithNoopRenderer', () => {
797
ReactNoop.discreteUpdates(() => {
798
setRow(5);
799
});
826
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
827
- React.startTransition(() => {
828
- setRow(20);
829
- });
830
- } else {
800
+ React.startTransition(() => {
801
setRow(20);
832
- }
802
+ });
803
});
804
expect(Scheduler).toHaveYielded(['Up', 'Down']);
805
expect(root).toMatchRenderedOutput(<span prop="Down" />);
@@ -1362,13 +1332,9 @@ describe('ReactHooksWithNoopRenderer', () => {
1332
]);
1333
1334
// Schedule another update for children, and partially process it.
1365
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
1366
- React.startTransition(() => {
1367
- setChildStates.forEach(setChildState => setChildState(2));
1368
- });
1369
- } else {
1335
+ React.startTransition(() => {
1336
setChildStates.forEach(setChildState => setChildState(2));
1371
- }
1337
+ });
1338
expect(Scheduler).toFlushAndYieldThrough(['Child one render']);
1339
1340
// Schedule unmount for the parent that unmounts children with pending update.
@@ -1674,42 +1640,24 @@ describe('ReactHooksWithNoopRenderer', () => {
1640
expect(ReactNoop).toMatchRenderedOutput(<span prop="Count: (empty)" />);
1641
1642
// Rendering again should flush the previous commit's effects
1677
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
1678
- React.startTransition(() => {
1679
- ReactNoop.render(<Counter count={1} />, () =>
1680
- Scheduler.unstable_yieldValue('Sync effect'),
1681
- );
1682
- });
1683
- } else {
1643
+ React.startTransition(() => {
1644
ReactNoop.render(<Counter count={1} />, () =>
1645
Scheduler.unstable_yieldValue('Sync effect'),
1646
);
1687
- }
1647
+ });
1648
1649
expect(Scheduler).toFlushAndYieldThrough([
1650
'Schedule update [0]',
1651
'Count: 0',
1652
]);
1653
1694
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
1695
- expect(ReactNoop).toMatchRenderedOutput(<span prop="Count: 0" />);
1696
- expect(Scheduler).toFlushAndYieldThrough([
1697
- 'Count: 0',
1698
- 'Sync effect',
1699
- 'Schedule update [1]',
1700
- 'Count: 1',
1701
- ]);
1702
- } else {
1703
- expect(ReactNoop).toMatchRenderedOutput(
1704
- <span prop="Count: (empty)" />,
1705
- );
1706
- expect(Scheduler).toFlushAndYieldThrough(['Sync effect']);
1707
- expect(ReactNoop).toMatchRenderedOutput(<span prop="Count: 0" />);
1708
-
1709
- ReactNoop.flushPassiveEffects();
1710
- expect(Scheduler).toHaveYielded(['Schedule update [1]']);
1711
- expect(Scheduler).toFlushAndYield(['Count: 1']);
1712
- }
1654
+ expect(ReactNoop).toMatchRenderedOutput(<span prop="Count: 0" />);
1655
+ expect(Scheduler).toFlushAndYieldThrough([
1656
+ 'Count: 0',
1657
+ 'Sync effect',
1658
+ 'Schedule update [1]',
1659
+ 'Count: 1',
1660
+ ]);
1661
1662
expect(ReactNoop).toMatchRenderedOutput(<span prop="Count: 1" />);
1663
});
packages/react-reconciler/src/__tests__/ReactIncremental-test.js
+20
-92
@@ -65,17 +65,11 @@ describe('ReactIncremental', () => {
65
return [<Bar key="a" isBar={true} />, <Bar key="b" isBar={true} />];
66
}
67
68
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
69
- React.startTransition(() => {
70
- ReactNoop.render(<Foo />, () =>
71
- Scheduler.unstable_yieldValue('callback'),
72
- );
73
- });
74
- } else {
68
+ React.startTransition(() => {
69
ReactNoop.render(<Foo />, () =>
70
Scheduler.unstable_yieldValue('callback'),
71
);
78
- }
72
+ });
73
// Do one step of work.
74
expect(ReactNoop.flushNextYield()).toEqual(['Foo']);
75
@@ -162,26 +156,18 @@ describe('ReactIncremental', () => {
156
ReactNoop.render(<Foo text="foo" />);
157
expect(Scheduler).toFlushAndYield(['Foo', 'Bar', 'Bar']);
158
165
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
166
- React.startTransition(() => {
167
- ReactNoop.render(<Foo text="bar" />);
168
- });
169
- } else {
159
+ React.startTransition(() => {
160
ReactNoop.render(<Foo text="bar" />);
171
- }
161
+ });
162
// Flush part of the work
163
expect(Scheduler).toFlushAndYieldThrough(['Foo', 'Bar']);
164
165
// This will abort the previous work and restart
166
ReactNoop.flushSync(() => ReactNoop.render(null));
167
178
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
179
- React.startTransition(() => {
180
- ReactNoop.render(<Foo text="baz" />);
181
- });
182
- } else {
168
+ React.startTransition(() => {
169
ReactNoop.render(<Foo text="baz" />);
184
- }
170
+ });
171
172
// Flush part of the new work
173
expect(Scheduler).toFlushAndYieldThrough(['Foo', 'Bar']);
@@ -215,17 +201,7 @@ describe('ReactIncremental', () => {
201
ReactNoop.render(<Foo />);
202
expect(Scheduler).toFlushWithoutYielding();
203
218
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
219
- React.startTransition(() => {
220
- inst.setState(
221
- () => {
222
- Scheduler.unstable_yieldValue('setState1');
223
- return {text: 'bar'};
224
- },
225
- () => Scheduler.unstable_yieldValue('callback1'),
226
- );
227
- });
228
- } else {
204
+ React.startTransition(() => {
205
inst.setState(
206
() => {
207
Scheduler.unstable_yieldValue('setState1');
@@ -233,24 +209,14 @@ describe('ReactIncremental', () => {
209
},
210
() => Scheduler.unstable_yieldValue('callback1'),
211
);
236
- }
212
+ });
213
214
// Flush part of the work
215
expect(Scheduler).toFlushAndYieldThrough(['setState1']);
216
217
// This will abort the previous work and restart
218
ReactNoop.flushSync(() => ReactNoop.render(<Foo />));
243
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
244
- React.startTransition(() => {
245
- inst.setState(
246
- () => {
247
- Scheduler.unstable_yieldValue('setState2');
248
- return {text2: 'baz'};
249
- },
250
- () => Scheduler.unstable_yieldValue('callback2'),
251
- );
252
- });
253
- } else {
219
+ React.startTransition(() => {
220
inst.setState(
221
() => {
222
Scheduler.unstable_yieldValue('setState2');
@@ -258,7 +224,7 @@ describe('ReactIncremental', () => {
224
},
225
() => Scheduler.unstable_yieldValue('callback2'),
226
);
261
- }
227
+ });
228
229
// Flush the rest of the work which now includes the low priority
230
expect(Scheduler).toFlushAndYield([
@@ -1878,18 +1844,7 @@ describe('ReactIncremental', () => {
1844
'ShowLocale {"locale":"de"}',
1845
'ShowBoth {"locale":"de"}',
1846
]);
1881
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
1882
- React.startTransition(() => {
1883
- ReactNoop.render(
1884
- <Intl locale="sv">
1885
- <ShowLocale />
1886
- <div>
1887
- <ShowBoth />
1888
- </div>
1889
- </Intl>,
1890
- );
1891
- });
1892
- } else {
1847
+ React.startTransition(() => {
1848
ReactNoop.render(
1849
<Intl locale="sv">
1850
<ShowLocale />
@@ -1898,7 +1853,7 @@ describe('ReactIncremental', () => {
1853
</div>
1854
</Intl>,
1855
);
1901
- }
1856
+ });
1857
expect(Scheduler).toFlushAndYieldThrough(['Intl {}']);
1858
1859
ReactNoop.render(
@@ -2028,22 +1983,7 @@ describe('ReactIncremental', () => {
1983
}
1984
}
1985
2031
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
2032
- React.startTransition(() => {
2033
- ReactNoop.render(
2034
- <Intl locale="fr">
2035
- <ShowLocale />
2036
- <LegacyHiddenDiv mode="hidden">
2037
- <ShowLocale />
2038
- <Intl locale="ru">
2039
- <ShowLocale />
2040
- </Intl>
2041
- </LegacyHiddenDiv>
2042
- <ShowLocale />
2043
- </Intl>,
2044
- );
2045
- });
2046
- } else {
1986
+ React.startTransition(() => {
1987
ReactNoop.render(
1988
<Intl locale="fr">
1989
<ShowLocale />
@@ -2056,7 +1996,7 @@ describe('ReactIncremental', () => {
1996
<ShowLocale />
1997
</Intl>,
1998
);
2059
- }
1999
+ });
2000
expect(Scheduler).toFlushAndYieldThrough([
2001
'Intl {}',
2002
'ShowLocale {"locale":"fr"}',
@@ -2746,13 +2686,9 @@ describe('ReactIncremental', () => {
2686
return null;
2687
}
2688
2749
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
2750
- React.startTransition(() => {
2751
- ReactNoop.render(<Parent step={1} />);
2752
- });
2753
- } else {
2689
+ React.startTransition(() => {
2690
ReactNoop.render(<Parent step={1} />);
2755
- }
2691
+ });
2692
expect(Scheduler).toFlushAndYieldThrough(['Parent: 1']);
2693
2694
// Interrupt at same priority
@@ -2772,13 +2708,9 @@ describe('ReactIncremental', () => {
2708
return null;
2709
}
2710
2775
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
2776
- React.startTransition(() => {
2777
- ReactNoop.render(<Parent step={1} />);
2778
- });
2779
- } else {
2711
+ React.startTransition(() => {
2712
ReactNoop.render(<Parent step={1} />);
2781
- }
2713
+ });
2714
expect(Scheduler).toFlushAndYieldThrough(['Parent: 1']);
2715
2716
// Interrupt at lower priority
@@ -2799,13 +2731,9 @@ describe('ReactIncremental', () => {
2731
return null;
2732
}
2733
2802
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
2803
- React.startTransition(() => {
2804
- ReactNoop.render(<Parent step={1} />);
2805
- });
2806
- } else {
2734
+ React.startTransition(() => {
2735
ReactNoop.render(<Parent step={1} />);
2808
- }
2736
+ });
2737
expect(Scheduler).toFlushAndYieldThrough(['Parent: 1']);
2738
2739
// Interrupt at higher priority
packages/react-reconciler/src/__tests__/ReactIncrementalErrorHandling-test.internal.js
+14
-76
@@ -87,23 +87,7 @@ describe('ReactIncrementalErrorHandling', () => {
87
throw new Error('oops!');
88
}
89
90
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
91
- React.startTransition(() => {
92
- ReactNoop.render(
93
- <ErrorBoundary>
94
- <Indirection>
95
- <Indirection>
96
- <Indirection>
97
- <BadRender />
98
- <Indirection />
99
- <Indirection />
100
- </Indirection>
101
- </Indirection>
102
- </Indirection>
103
- </ErrorBoundary>,
104
- );
105
- });
106
- } else {
90
+ React.startTransition(() => {
91
ReactNoop.render(
92
<ErrorBoundary>
93
<Indirection>
@@ -117,7 +101,7 @@ describe('ReactIncrementalErrorHandling', () => {
101
</Indirection>
102
</ErrorBoundary>,
103
);
120
- }
104
+ });
105
106
// Start rendering asynchronously
107
expect(Scheduler).toFlushAndYieldThrough([
@@ -201,23 +185,7 @@ describe('ReactIncrementalErrorHandling', () => {
185
throw new Error('oops!');
186
}
187
204
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
205
- React.startTransition(() => {
206
- ReactNoop.render(
207
- <ErrorBoundary>
208
- <Indirection>
209
- <Indirection>
210
- <Indirection>
211
- <BadRender />
212
- <Indirection />
213
- <Indirection />
214
- </Indirection>
215
- </Indirection>
216
- </Indirection>
217
- </ErrorBoundary>,
218
- );
219
- });
220
- } else {
188
+ React.startTransition(() => {
189
ReactNoop.render(
190
<ErrorBoundary>
191
<Indirection>
@@ -231,7 +199,7 @@ describe('ReactIncrementalErrorHandling', () => {
199
</Indirection>
200
</ErrorBoundary>,
201
);
234
- }
202
+ });
203
204
// Start rendering asynchronously
205
expect(Scheduler).toFlushAndYieldThrough([
@@ -399,17 +367,11 @@ describe('ReactIncrementalErrorHandling', () => {
367
);
368
}
369
402
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
403
- React.startTransition(() => {
404
- ReactNoop.render(<Parent />, () =>
405
- Scheduler.unstable_yieldValue('commit'),
406
- );
407
- });
408
- } else {
370
+ React.startTransition(() => {
371
ReactNoop.render(<Parent />, () =>
372
Scheduler.unstable_yieldValue('commit'),
373
);
412
- }
374
+ });
375
376
// Render the bad component asynchronously
377
expect(Scheduler).toFlushAndYieldThrough(['Parent', 'BadRender']);
@@ -451,13 +413,9 @@ describe('ReactIncrementalErrorHandling', () => {
413
);
414
}
415
454
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
455
- React.startTransition(() => {
456
- ReactNoop.render(<App />);
457
- });
458
- } else {
416
+ React.startTransition(() => {
417
ReactNoop.render(<App />);
460
- }
418
+ });
419
420
// Render part of the tree
421
expect(Scheduler).toFlushAndYieldThrough(['A', 'B']);
@@ -592,21 +550,13 @@ describe('ReactIncrementalErrorHandling', () => {
550
throw new Error('Hello');
551
}
552
595
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
596
- React.startTransition(() => {
597
- ReactNoop.render(
598
- <ErrorBoundary>
599
- <BrokenRender />
600
- </ErrorBoundary>,
601
- );
602
- });
603
- } else {
553
+ React.startTransition(() => {
554
ReactNoop.render(
555
<ErrorBoundary>
556
<BrokenRender />
557
</ErrorBoundary>,
558
);
609
- }
559
+ });
560
561
expect(Scheduler).toFlushAndYieldThrough(['ErrorBoundary render success']);
562
expect(ReactNoop).toMatchRenderedOutput(null);
@@ -781,21 +731,13 @@ describe('ReactIncrementalErrorHandling', () => {
731
throw new Error('Hello');
732
}
733
784
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
785
- React.startTransition(() => {
786
- ReactNoop.render(
787
- <RethrowErrorBoundary>
788
- <BrokenRender />
789
- </RethrowErrorBoundary>,
790
- );
791
- });
792
- } else {
734
+ React.startTransition(() => {
735
ReactNoop.render(
736
<RethrowErrorBoundary>
737
<BrokenRender />
738
</RethrowErrorBoundary>,
739
);
798
- }
740
+ });
741
742
expect(Scheduler).toFlushAndYieldThrough(['RethrowErrorBoundary render']);
743
@@ -1875,13 +1817,9 @@ describe('ReactIncrementalErrorHandling', () => {
1817
}
1818
1819
await act(async () => {
1878
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
1879
- React.startTransition(() => {
1880
- root.render(<Oops />);
1881
- });
1882
- } else {
1820
+ React.startTransition(() => {
1821
root.render(<Oops />);
1884
- }
1822
+ });
1823
1824
// Render past the component that throws, then yield.
1825
expect(Scheduler).toFlushAndYieldThrough(['Oops']);
packages/react-reconciler/src/__tests__/ReactIncrementalReflection-test.js
+10
-30
@@ -63,13 +63,9 @@ describe('ReactIncrementalReflection', () => {
63
return <Component />;
64
}
65
66
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
67
- React.startTransition(() => {
68
- ReactNoop.render(<Foo />);
69
- });
70
- } else {
66
+ React.startTransition(() => {
67
ReactNoop.render(<Foo />);
72
- }
68
+ });
69
70
// Render part way through but don't yet commit the updates.
71
expect(Scheduler).toFlushAndYieldThrough(['componentWillMount: false']);
@@ -117,13 +113,9 @@ describe('ReactIncrementalReflection', () => {
113
114
expect(instances[0]._isMounted()).toBe(true);
115
120
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
121
- React.startTransition(() => {
122
- ReactNoop.render(<Foo mount={false} />);
123
- });
124
- } else {
116
+ React.startTransition(() => {
117
ReactNoop.render(<Foo mount={false} />);
126
- }
118
+ });
119
// Render part way through but don't yet commit the updates so it is not
120
// fully unmounted yet.
121
expect(Scheduler).toFlushAndYieldThrough(['Other']);
@@ -206,13 +198,9 @@ describe('ReactIncrementalReflection', () => {
198
return [<Component key="a" step={props.step} />, <Sibling key="b" />];
199
}
200
209
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
210
- React.startTransition(() => {
211
- ReactNoop.render(<Foo step={0} />);
212
- });
213
- } else {
201
+ React.startTransition(() => {
202
ReactNoop.render(<Foo step={0} />);
215
- }
203
+ });
204
// Flush past Component but don't complete rendering everything yet.
205
expect(Scheduler).toFlushAndYieldThrough([
206
['componentWillMount', null],
@@ -246,13 +234,9 @@ describe('ReactIncrementalReflection', () => {
234
235
// The next step will render a new host node but won't get committed yet.
236
// We expect this to mutate the original Fiber.
249
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
250
- React.startTransition(() => {
251
- ReactNoop.render(<Foo step={2} />);
252
- });
253
- } else {
237
+ React.startTransition(() => {
238
ReactNoop.render(<Foo step={2} />);
255
- }
239
+ });
240
expect(Scheduler).toFlushAndYieldThrough([
241
['componentWillUpdate', hostSpan],
242
'render',
@@ -273,13 +257,9 @@ describe('ReactIncrementalReflection', () => {
257
expect(ReactNoop.findInstance(classInstance)).toBe(hostDiv);
258
259
// Render to null but don't commit it yet.
276
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
277
- React.startTransition(() => {
278
- ReactNoop.render(<Foo step={3} />);
279
- });
280
- } else {
260
+ React.startTransition(() => {
261
ReactNoop.render(<Foo step={3} />);
282
- }
262
+ });
263
expect(Scheduler).toFlushAndYieldThrough([
264
['componentWillUpdate', hostDiv],
265
'render',
packages/react-reconciler/src/__tests__/ReactIncrementalScheduling-test.js
+10
-31
@@ -105,15 +105,10 @@ describe('ReactIncrementalScheduling', () => {
105
106
// Schedule deferred work in the reverse order
107
act(() => {
108
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
109
- React.startTransition(() => {
110
- ReactNoop.renderToRootWithID(<Text text="c:2" />, 'c');
111
- ReactNoop.renderToRootWithID(<Text text="b:2" />, 'b');
112
- });
113
- } else {
108
+ React.startTransition(() => {
109
ReactNoop.renderToRootWithID(<Text text="c:2" />, 'c');
110
ReactNoop.renderToRootWithID(<Text text="b:2" />, 'b');
116
- }
111
+ });
112
// Ensure it starts in the order it was scheduled
113
expect(Scheduler).toFlushAndYieldThrough(['c:2']);
114
@@ -122,13 +117,9 @@ describe('ReactIncrementalScheduling', () => {
117
expect(ReactNoop.getChildrenAsJSX('c')).toEqual('c:2');
118
// Schedule last bit of work, it will get processed the last
119
125
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
126
- React.startTransition(() => {
127
- ReactNoop.renderToRootWithID(<Text text="a:2" />, 'a');
128
- });
129
- } else {
120
+ React.startTransition(() => {
121
ReactNoop.renderToRootWithID(<Text text="a:2" />, 'a');
131
- }
122
+ });
123
124
// Keep performing work in the order it was scheduled
125
expect(Scheduler).toFlushAndYieldThrough(['b:2']);
@@ -181,13 +172,9 @@ describe('ReactIncrementalScheduling', () => {
172
}
173
}
174
184
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
185
- React.startTransition(() => {
186
- ReactNoop.render(<Foo />);
187
- });
188
- } else {
175
+ React.startTransition(() => {
176
ReactNoop.render(<Foo />);
190
- }
177
+ });
178
// Render without committing
179
expect(Scheduler).toFlushAndYieldThrough(['render: 0']);
180
@@ -201,13 +188,9 @@ describe('ReactIncrementalScheduling', () => {
188
'componentDidUpdate: 1',
189
]);
190
204
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
205
- React.startTransition(() => {
206
- instance.setState({tick: 2});
207
- });
208
- } else {
191
+ React.startTransition(() => {
192
instance.setState({tick: 2});
210
- }
193
+ });
194
expect(Scheduler).toFlushAndYieldThrough(['render: 2']);
195
expect(ReactNoop.flushNextYield()).toEqual([
196
'componentDidUpdate: 2',
@@ -310,13 +293,9 @@ describe('ReactIncrementalScheduling', () => {
293
return <span prop={this.state.step} />;
294
}
295
}
313
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
314
- React.startTransition(() => {
315
- ReactNoop.render(<Foo />);
316
- });
317
- } else {
296
+ React.startTransition(() => {
297
ReactNoop.render(<Foo />);
319
- }
298
+ });
299
300
// This should be just enough to complete all the work, but not enough to
301
// commit it.
packages/react-reconciler/src/__tests__/ReactIncrementalSideEffects-test.js
+8
-24
@@ -456,13 +456,9 @@ describe('ReactIncrementalSideEffects', () => {
456
</div>,
457
);
458
459
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
460
- React.startTransition(() => {
461
- ReactNoop.render(<Foo text="World" />);
462
- });
463
- } else {
459
+ React.startTransition(() => {
460
ReactNoop.render(<Foo text="World" />);
465
- }
461
+ });
462
463
// Flush some of the work without committing
464
expect(Scheduler).toFlushAndYieldThrough(['Foo', 'Bar']);
@@ -697,13 +693,9 @@ describe('ReactIncrementalSideEffects', () => {
693
Scheduler.unstable_yieldValue('Foo');
694
return <span prop={props.step} />;
695
}
700
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
701
- React.startTransition(() => {
702
- ReactNoop.render(<Foo step={1} />);
703
- });
704
- } else {
696
+ React.startTransition(() => {
697
ReactNoop.render(<Foo step={1} />);
706
- }
698
+ });
699
// This should be just enough to complete the tree without committing it
700
expect(Scheduler).toFlushAndYieldThrough(['Foo']);
701
expect(ReactNoop.getChildrenAsJSX()).toEqual(null);
@@ -712,26 +704,18 @@ describe('ReactIncrementalSideEffects', () => {
704
ReactNoop.flushNextYield();
705
expect(ReactNoop.getChildrenAsJSX()).toEqual(<span prop={1} />);
706
715
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
716
- React.startTransition(() => {
717
- ReactNoop.render(<Foo step={2} />);
718
- });
719
- } else {
707
+ React.startTransition(() => {
708
ReactNoop.render(<Foo step={2} />);
721
- }
709
+ });
710
// This should be just enough to complete the tree without committing it
711
expect(Scheduler).toFlushAndYieldThrough(['Foo']);
712
expect(ReactNoop.getChildrenAsJSX()).toEqual(<span prop={1} />);
713
// This time, before we commit the tree, we update the root component with
714
// new props
715
728
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
729
- React.startTransition(() => {
730
- ReactNoop.render(<Foo step={3} />);
731
- });
732
- } else {
716
+ React.startTransition(() => {
717
ReactNoop.render(<Foo step={3} />);
734
- }
718
+ });
719
expect(ReactNoop.getChildrenAsJSX()).toEqual(<span prop={1} />);
720
// Now let's commit. We already had a commit that was pending, which will
721
// render 2.
packages/react-reconciler/src/__tests__/ReactIncrementalUpdates-test.js
+22
-86
@@ -152,21 +152,11 @@ describe('ReactIncrementalUpdates', () => {
152
}
153
154
// Schedule some async updates
155
- if (
156
- gate(
157
- flags => flags.enableSyncDefaultUpdates || flags.enableUnifiedSyncLane,
158
- )
159
- ) {
160
- React.startTransition(() => {
161
- instance.setState(createUpdate('a'));
162
- instance.setState(createUpdate('b'));
163
- instance.setState(createUpdate('c'));
164
- });
165
- } else {
155
+ React.startTransition(() => {
156
instance.setState(createUpdate('a'));
157
instance.setState(createUpdate('b'));
158
instance.setState(createUpdate('c'));
169
- }
159
+ });
160
161
// Begin the updates but don't flush them yet
162
expect(Scheduler).toFlushAndYieldThrough(['a', 'b', 'c']);
@@ -183,11 +173,7 @@ describe('ReactIncrementalUpdates', () => {
173
});
174
175
// The sync updates should have flushed, but not the async ones.
186
- if (
187
- gate(
188
- flags => flags.enableSyncDefaultUpdates && flags.enableUnifiedSyncLane,
189
- )
190
- ) {
176
+ if (gate(flags => flags.enableUnifiedSyncLane)) {
177
expect(Scheduler).toHaveYielded(['d', 'e', 'f']);
178
expect(ReactNoop).toMatchRenderedOutput(<span prop="def" />);
179
} else {
@@ -199,11 +185,7 @@ describe('ReactIncrementalUpdates', () => {
185
// Now flush the remaining work. Even though e and f were already processed,
186
// they should be processed again, to ensure that the terminal state
187
// is deterministic.
202
- if (
203
- gate(
204
- flags => flags.enableSyncDefaultUpdates && !flags.enableUnifiedSyncLane,
205
- )
206
- ) {
188
+ if (gate(flags => !flags.enableUnifiedSyncLane)) {
189
expect(Scheduler).toFlushAndYield([
190
// Since 'g' is in a transition, we'll process 'd' separately first.
191
// That causes us to process 'd' with 'e' and 'f' rebased.
@@ -257,21 +239,11 @@ describe('ReactIncrementalUpdates', () => {
239
}
240
241
// Schedule some async updates
260
- if (
261
- gate(
262
- flags => flags.enableSyncDefaultUpdates || flags.enableUnifiedSyncLane,
263
- )
264
- ) {
265
- React.startTransition(() => {
266
- instance.setState(createUpdate('a'));
267
- instance.setState(createUpdate('b'));
268
- instance.setState(createUpdate('c'));
269
- });
270
- } else {
242
+ React.startTransition(() => {
243
instance.setState(createUpdate('a'));
244
instance.setState(createUpdate('b'));
245
instance.setState(createUpdate('c'));
274
- }
246
+ });
247
248
// Begin the updates but don't flush them yet
249
expect(Scheduler).toFlushAndYieldThrough(['a', 'b', 'c']);
@@ -291,11 +263,7 @@ describe('ReactIncrementalUpdates', () => {
263
});
264
265
// The sync updates should have flushed, but not the async ones.
294
- if (
295
- gate(
296
- flags => flags.enableSyncDefaultUpdates && flags.enableUnifiedSyncLane,
297
- )
298
- ) {
266
+ if (gate(flags => flags.enableUnifiedSyncLane)) {
267
expect(Scheduler).toHaveYielded(['d', 'e', 'f']);
268
} else {
269
// Update d was dropped and replaced by e.
@@ -306,11 +274,7 @@ describe('ReactIncrementalUpdates', () => {
274
// Now flush the remaining work. Even though e and f were already processed,
275
// they should be processed again, to ensure that the terminal state
276
// is deterministic.
309
- if (
310
- gate(
311
- flags => flags.enableSyncDefaultUpdates && !flags.enableUnifiedSyncLane,
312
- )
313
- ) {
277
+ if (gate(flags => !flags.enableUnifiedSyncLane)) {
278
expect(Scheduler).toFlushAndYield([
279
// Since 'g' is in a transition, we'll process 'd' separately first.
280
// That causes us to process 'd' with 'e' and 'f' rebased.
@@ -566,13 +530,9 @@ describe('ReactIncrementalUpdates', () => {
530
}
531
532
act(() => {
569
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
570
- React.startTransition(() => {
571
- ReactNoop.render(<App />);
572
- });
573
- } else {
533
+ React.startTransition(() => {
534
ReactNoop.render(<App />);
575
- }
535
+ });
536
flushNextRenderIfExpired();
537
expect(Scheduler).toHaveYielded([]);
538
expect(Scheduler).toFlushAndYield([
@@ -582,13 +542,9 @@ describe('ReactIncrementalUpdates', () => {
542
]);
543
544
Scheduler.unstable_advanceTime(10000);
585
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
586
- React.startTransition(() => {
587
- setCount(2);
588
- });
589
- } else {
545
+ React.startTransition(() => {
546
setCount(2);
591
- }
547
+ });
548
flushNextRenderIfExpired();
549
expect(Scheduler).toHaveYielded([]);
550
});
@@ -607,13 +563,9 @@ describe('ReactIncrementalUpdates', () => {
563
564
Scheduler.unstable_advanceTime(10000);
565
610
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
611
- React.startTransition(() => {
612
- ReactNoop.render(<Text text="B" />);
613
- });
614
- } else {
566
+ React.startTransition(() => {
567
ReactNoop.render(<Text text="B" />);
616
- }
568
+ });
569
flushNextRenderIfExpired();
570
expect(Scheduler).toHaveYielded([]);
571
});
@@ -624,26 +576,18 @@ describe('ReactIncrementalUpdates', () => {
576
return text;
577
}
578
627
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
628
- React.startTransition(() => {
629
- ReactNoop.render(<Text text="A" />);
630
- });
631
- } else {
579
+ React.startTransition(() => {
580
ReactNoop.render(<Text text="A" />);
633
- }
581
+ });
582
Scheduler.unstable_advanceTime(10000);
583
flushNextRenderIfExpired();
584
expect(Scheduler).toHaveYielded(['A']);
585
586
Scheduler.unstable_advanceTime(10000);
587
640
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
641
- React.startTransition(() => {
642
- ReactNoop.render(<Text text="B" />);
643
- });
644
- } else {
588
+ React.startTransition(() => {
589
ReactNoop.render(<Text text="B" />);
646
- }
590
+ });
591
flushNextRenderIfExpired();
592
expect(Scheduler).toHaveYielded([]);
593
});
@@ -680,13 +624,9 @@ describe('ReactIncrementalUpdates', () => {
624
expect(root).toMatchRenderedOutput(null);
625
626
await act(async () => {
683
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
684
- React.startTransition(() => {
685
- pushToLog('A');
686
- });
687
- } else {
627
+ React.startTransition(() => {
628
pushToLog('A');
689
- }
629
+ });
630
631
ReactNoop.unstable_runWithPriority(ContinuousEventPriority, () =>
632
pushToLog('B'),
@@ -749,13 +689,9 @@ describe('ReactIncrementalUpdates', () => {
689
expect(root).toMatchRenderedOutput(null);
690
691
await act(async () => {
752
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
753
- React.startTransition(() => {
754
- pushToLog('A');
755
- });
756
- } else {
692
+ React.startTransition(() => {
693
pushToLog('A');
758
- }
694
+ });
695
ReactNoop.unstable_runWithPriority(ContinuousEventPriority, () =>
696
pushToLog('B'),
697
);
packages/react-reconciler/src/__tests__/ReactInterleavedUpdates-test.js
+3
-66
@@ -57,78 +57,15 @@ describe('ReactInterleavedUpdates', () => {
57
expect(root).toMatchRenderedOutput('000');
58
59
await act(async () => {
60
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
61
- React.startTransition(() => {
62
- updateChildren(1);
63
- });
64
- } else {
60
+ React.startTransition(() => {
61
updateChildren(1);
66
- }
67
- // Partially render the children. Only the first one.
68
- expect(Scheduler).toFlushAndYieldThrough([1]);
69
-
70
- // In an interleaved event, schedule an update on each of the children.
71
- // Including the two that haven't rendered yet.
72
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
73
- React.startTransition(() => {
74
- updateChildren(2);
75
- });
76
- } else {
77
- updateChildren(2);
78
- }
79
-
80
- // We should continue rendering without including the interleaved updates.
81
- expect(Scheduler).toFlushUntilNextPaint([1, 1]);
82
- expect(root).toMatchRenderedOutput('111');
83
- });
84
- // The interleaved updates flush in a separate render.
85
- expect(Scheduler).toHaveYielded([2, 2, 2]);
86
- expect(root).toMatchRenderedOutput('222');
87
- });
88
-
89
- // @gate !enableSyncDefaultUpdates
90
- test('low priority update during an interleaved event is not processed during the current render', async () => {
91
- // Same as previous test, but the interleaved update is lower priority than
92
- // the in-progress render.
93
- const updaters = [];
94
-
95
- function Child() {
96
- const [state, setState] = useState(0);
97
- useEffect(() => {
98
- updaters.push(setState);
99
- }, []);
100
- return <Text text={state} />;
101
- }
102
-
103
- function updateChildren(value) {
104
- for (let i = 0; i < updaters.length; i++) {
105
- const setState = updaters[i];
106
- setState(value);
107
- }
108
- }
109
-
110
- const root = ReactNoop.createRoot();
111
-
112
- await act(async () => {
113
- root.render(
114
- <>
115
- <Child />
116
- <Child />
117
- <Child />
118
- </>,
119
- );
120
- });
121
- expect(Scheduler).toHaveYielded([0, 0, 0]);
122
- expect(root).toMatchRenderedOutput('000');
123
-
124
- await act(async () => {
125
- updateChildren(1);
62
+ });
63
// Partially render the children. Only the first one.
64
expect(Scheduler).toFlushAndYieldThrough([1]);
65
66
// In an interleaved event, schedule an update on each of the children.
67
// Including the two that haven't rendered yet.
131
- startTransition(() => {
68
+ React.startTransition(() => {
69
updateChildren(2);
70
});
71
packages/react-reconciler/src/__tests__/ReactLazy-test.internal.js
+2
-6
@@ -1560,13 +1560,9 @@ describe('ReactLazy', () => {
1560
expect(root).toMatchRenderedOutput('AB');
1561
1562
// Swap the position of A and B
1563
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
1564
- React.startTransition(() => {
1565
- root.update(<Parent swap={true} />);
1566
- });
1567
- } else {
1563
+ React.startTransition(() => {
1564
root.update(<Parent swap={true} />);
1569
- }
1565
+ });
1566
expect(Scheduler).toFlushAndYield(['Init B2', 'Loading...']);
1567
await lazyChildB2;
1568
// We need to flush to trigger the second one to load.
packages/react-reconciler/src/__tests__/ReactNewContext-test.js
+4
-12
@@ -881,13 +881,9 @@ describe('ReactNewContext', () => {
881
);
882
}
883
884
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
885
- React.startTransition(() => {
886
- ReactNoop.render(<App value={1} />);
887
- });
888
- } else {
884
+ React.startTransition(() => {
885
ReactNoop.render(<App value={1} />);
890
- }
886
+ });
887
// Render past the Provider, but don't commit yet
888
expect(Scheduler).toFlushAndYieldThrough(['Foo']);
889
@@ -927,13 +923,9 @@ describe('ReactNewContext', () => {
923
);
924
}
925
930
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
931
- React.startTransition(() => {
932
- ReactNoop.render(<App value={1} />);
933
- });
934
- } else {
926
+ React.startTransition(() => {
927
ReactNoop.render(<App value={1} />);
936
- }
928
+ });
929
expect(Scheduler).toFlushAndYield(['Foo', 'Foo']);
930
931
// Get a new copy of ReactNoop
packages/react-reconciler/src/__tests__/ReactSchedulerIntegration-test.js
+2
-6
@@ -102,13 +102,9 @@ describe('ReactSchedulerIntegration', () => {
102
scheduleCallback(NormalPriority, () => Scheduler.unstable_yieldValue('C'));
103
104
// Schedule a React render. React will request a paint after committing it.
105
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
106
- React.startTransition(() => {
107
- root.render('Update');
108
- });
109
- } else {
105
+ React.startTransition(() => {
106
root.render('Update');
111
- }
107
+ });
108
109
// Advance time just to be sure the next tasks have lower priority
110
Scheduler.unstable_advanceTime(2000);
packages/react-reconciler/src/__tests__/ReactSuspense-test.internal.js
+4
-91
@@ -124,13 +124,9 @@ describe('ReactSuspense', () => {
124
125
// Navigate the shell to now render the child content.
126
// This should suspend.
127
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
128
- React.startTransition(() => {
129
- root.update(<Foo renderBar={true} />);
130
- });
131
- } else {
127
+ React.startTransition(() => {
128
root.update(<Foo renderBar={true} />);
133
- }
129
+ });
130
131
expect(Scheduler).toFlushAndYield([
132
'Foo',
@@ -239,19 +235,7 @@ describe('ReactSuspense', () => {
235
expect(root).toMatchRenderedOutput('Initial');
236
237
// The update will suspend.
242
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
243
- React.startTransition(() => {
244
- root.update(
245
- <>
246
- <Suspense fallback={<Text text="Loading..." />}>
247
- <Async />
248
- </Suspense>
249
- <Text text="After Suspense" />
250
- <Text text="Sibling" />
251
- </>,
252
- );
253
- });
254
- } else {
238
+ React.startTransition(() => {
239
root.update(
240
<>
241
<Suspense fallback={<Text text="Loading..." />}>
@@ -261,8 +245,7 @@ describe('ReactSuspense', () => {
245
<Text text="Sibling" />
246
</>,
247
);
264
- }
265
-
248
+ });
249
// Yield past the Suspense boundary but don't complete the last sibling.
250
expect(Scheduler).toFlushAndYieldThrough([
251
'Suspend!',
@@ -396,76 +379,6 @@ describe('ReactSuspense', () => {
379
expect(root).toMatchRenderedOutput('AB');
380
});
381
399
- // @gate !enableSyncDefaultUpdates
400
- it(
401
- 'interrupts current render when something suspends with a ' +
402
- "delay and we've already skipped over a lower priority update in " +
403
- 'a parent',
404
- () => {
405
- function interrupt() {
406
- // React has a heuristic to batch all updates that occur within the same
407
- // event. This is a trick to circumvent that heuristic.
408
- ReactTestRenderer.create('whatever');
409
- }
410
-
411
- function App({shouldSuspend, step}) {
412
- return (
413
- <>
414
- <Text text={`A${step}`} />
415
- <Suspense fallback={<Text text="Loading..." />}>
416
- {shouldSuspend ? <AsyncText text="Async" ms={2000} /> : null}
417
- </Suspense>
418
- <Text text={`B${step}`} />
419
- <Text text={`C${step}`} />
420
- </>
421
- );
422
- }
423
-
424
- const root = ReactTestRenderer.create(null, {
425
- unstable_isConcurrent: true,
426
- });
427
-
428
- root.update(<App shouldSuspend={false} step={0} />);
429
- expect(Scheduler).toFlushAndYield(['A0', 'B0', 'C0']);
430
- expect(root).toMatchRenderedOutput('A0B0C0');
431
-
432
- // This update will suspend.
433
- root.update(<App shouldSuspend={true} step={1} />);
434
-
435
- // Do a bit of work
436
- expect(Scheduler).toFlushAndYieldThrough(['A1']);
437
-
438
- // Schedule another update. This will have lower priority because it's
439
- // a transition.
440
- React.startTransition(() => {
441
- root.update(<App shouldSuspend={false} step={2} />);
442
- });
443
-
444
- // Interrupt to trigger a restart.
445
- interrupt();
446
-
447
- expect(Scheduler).toFlushAndYieldThrough([
448
- // Should have restarted the first update, because of the interruption
449
- 'A1',
450
- 'Suspend! [Async]',
451
- 'Loading...',
452
- 'B1',
453
- ]);
454
-
455
- // Should not have committed loading state
456
- expect(root).toMatchRenderedOutput('A0B0C0');
457
-
458
- // After suspending, should abort the first update and switch to the
459
- // second update. So, C1 should not appear in the log.
460
- // TODO: This should work even if React does not yield to the main
461
- // thread. Should use same mechanism as selective hydration to interrupt
462
- // the render before the end of the current slice of work.
463
- expect(Scheduler).toFlushAndYield(['A2', 'B2', 'C2']);
464
-
465
- expect(root).toMatchRenderedOutput('A2B2C2');
466
- },
467
- );
468
-
382
it('mounts a lazy class component in non-concurrent mode', async () => {
383
class Class extends React.Component {
384
componentDidMount() {
packages/react-reconciler/src/__tests__/ReactSuspenseList-test.js
+10
-34
@@ -1362,13 +1362,9 @@ describe('ReactSuspenseList', () => {
1362
}
1363
1364
// This render is only CPU bound. Nothing suspends.
1365
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
1366
- React.startTransition(() => {
1367
- ReactNoop.render(<Foo />);
1368
- });
1369
- } else {
1365
+ React.startTransition(() => {
1366
ReactNoop.render(<Foo />);
1371
- }
1367
+ });
1368
1369
expect(Scheduler).toFlushAndYieldThrough(['A']);
1370
@@ -1546,13 +1542,9 @@ describe('ReactSuspenseList', () => {
1542
}
1543
1544
// This render is only CPU bound. Nothing suspends.
1549
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
1550
- React.startTransition(() => {
1551
- ReactNoop.render(<Foo />);
1552
- });
1553
- } else {
1545
+ React.startTransition(() => {
1546
ReactNoop.render(<Foo />);
1555
- }
1547
+ });
1548
1549
expect(Scheduler).toFlushAndYieldThrough(['A']);
1550
@@ -2548,15 +2540,9 @@ describe('ReactSuspenseList', () => {
2540
expect(ReactNoop).toMatchRenderedOutput(null);
2541
2542
await act(async () => {
2551
- // Add a few items at the end.
2552
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
2553
- React.startTransition(() => {
2554
- updateLowPri(true);
2555
- });
2556
- } else {
2543
+ React.startTransition(() => {
2544
updateLowPri(true);
2558
- }
2559
-
2545
+ });
2546
// Flush partially through.
2547
expect(Scheduler).toFlushAndYieldThrough(['B', 'C']);
2548
@@ -2692,14 +2678,9 @@ describe('ReactSuspenseList', () => {
2678
);
2679
}
2680
2695
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
2696
- React.startTransition(() => {
2697
- ReactNoop.render(<App />);
2698
- });
2699
- } else {
2681
+ React.startTransition(() => {
2682
ReactNoop.render(<App />);
2701
- }
2702
-
2683
+ });
2684
expect(Scheduler).toFlushAndYieldThrough([
2685
'App',
2686
'First Pass A',
@@ -2765,14 +2746,9 @@ describe('ReactSuspenseList', () => {
2746
);
2747
}
2748
2768
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
2769
- React.startTransition(() => {
2770
- ReactNoop.render(<App />);
2771
- });
2772
- } else {
2749
+ React.startTransition(() => {
2750
ReactNoop.render(<App />);
2774
- }
2775
-
2751
+ });
2752
expect(Scheduler).toFlushAndYieldThrough([
2753
'App',
2754
'First Pass A',
packages/react-reconciler/src/__tests__/ReactSuspenseWithNoopRenderer-test.js
+44
-266
@@ -205,13 +205,9 @@ describe('ReactSuspenseWithNoopRenderer', () => {
205
);
206
}
207
208
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
209
- React.startTransition(() => {
210
- ReactNoop.render(<Foo />);
211
- });
212
- } else {
208
+ React.startTransition(() => {
209
ReactNoop.render(<Foo />);
214
- }
210
+ });
211
expect(Scheduler).toFlushAndYieldThrough([
212
'Foo',
213
'Bar',
@@ -281,13 +277,9 @@ describe('ReactSuspenseWithNoopRenderer', () => {
277
expect(Scheduler).toFlushAndYield(['Foo']);
278
279
// The update will suspend.
284
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
285
- React.startTransition(() => {
286
- ReactNoop.render(<Foo renderBar={true} />);
287
- });
288
- } else {
280
+ React.startTransition(() => {
281
ReactNoop.render(<Foo renderBar={true} />);
290
- }
282
+ });
283
expect(Scheduler).toFlushAndYield([
284
'Foo',
285
'Bar',
@@ -368,18 +360,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
360
ReactNoop.render(<Suspense fallback={<Text text="Loading..." />} />);
361
expect(Scheduler).toFlushAndYield([]);
362
// B suspends. Continue rendering the remaining siblings.
371
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
372
- React.startTransition(() => {
373
- ReactNoop.render(
374
- <Suspense fallback={<Text text="Loading..." />}>
375
- <Text text="A" />
376
- <AsyncText text="B" />
377
- <Text text="C" />
378
- <Text text="D" />
379
- </Suspense>,
380
- );
381
- });
382
- } else {
363
+ React.startTransition(() => {
364
ReactNoop.render(
365
<Suspense fallback={<Text text="Loading..." />}>
366
<Text text="A" />
@@ -388,7 +369,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
369
<Text text="D" />
370
</Suspense>,
371
);
391
- }
372
+ });
373
// B suspends. Continue rendering the remaining siblings.
374
expect(Scheduler).toFlushAndYield([
375
'A',
@@ -452,13 +433,9 @@ describe('ReactSuspenseWithNoopRenderer', () => {
433
expect(Scheduler).toFlushAndYield([]);
434
expect(ReactNoop).toMatchRenderedOutput(null);
435
455
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
456
- React.startTransition(() => {
457
- ReactNoop.render(<App renderContent={true} />);
458
- });
459
- } else {
436
+ React.startTransition(() => {
437
ReactNoop.render(<App renderContent={true} />);
461
- }
438
+ });
439
expect(Scheduler).toFlushAndYield(['Suspend! [Result]', 'Loading...']);
440
expect(ReactNoop).toMatchRenderedOutput(null);
441
@@ -603,26 +580,18 @@ describe('ReactSuspenseWithNoopRenderer', () => {
580
expect(Scheduler).toFlushAndYield([]);
581
expect(ReactNoop).toMatchRenderedOutput(null);
582
606
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
607
- React.startTransition(() => {
608
- ReactNoop.render(<App showA={true} showB={false} />);
609
- });
610
- } else {
583
+ React.startTransition(() => {
584
ReactNoop.render(<App showA={true} showB={false} />);
612
- }
585
+ });
586
expect(Scheduler).toFlushAndYield(['Suspend! [A]', 'Loading...']);
587
expect(ReactNoop).toMatchRenderedOutput(null);
588
589
// Advance React's virtual time by enough to fall into a new async bucket,
590
// but not enough to expire the suspense timeout.
591
ReactNoop.expire(120);
619
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
620
- React.startTransition(() => {
621
- ReactNoop.render(<App showA={true} showB={true} />);
622
- });
623
- } else {
592
+ React.startTransition(() => {
593
ReactNoop.render(<App showA={true} showB={true} />);
625
- }
594
+ });
595
expect(Scheduler).toFlushAndYield(['Suspend! [A]', 'B', 'Loading...']);
596
expect(ReactNoop).toMatchRenderedOutput(null);
597
@@ -704,35 +673,23 @@ describe('ReactSuspenseWithNoopRenderer', () => {
673
674
// Schedule an update at several distinct expiration times
675
await act(async () => {
707
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
708
- React.startTransition(() => {
709
- root.render(<App step={1} shouldSuspend={true} />);
710
- });
711
- } else {
676
+ React.startTransition(() => {
677
root.render(<App step={1} shouldSuspend={true} />);
713
- }
678
+ });
679
Scheduler.unstable_advanceTime(1000);
680
expect(Scheduler).toFlushAndYieldThrough(['Sibling']);
681
interrupt();
682
718
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
719
- React.startTransition(() => {
720
- root.render(<App step={2} shouldSuspend={true} />);
721
- });
722
- } else {
683
+ React.startTransition(() => {
684
root.render(<App step={2} shouldSuspend={true} />);
724
- }
685
+ });
686
Scheduler.unstable_advanceTime(1000);
687
expect(Scheduler).toFlushAndYieldThrough(['Sibling']);
688
interrupt();
689
729
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
730
- React.startTransition(() => {
731
- root.render(<App step={3} shouldSuspend={true} />);
732
- });
733
- } else {
690
+ React.startTransition(() => {
691
root.render(<App step={3} shouldSuspend={true} />);
735
- }
692
+ });
693
Scheduler.unstable_advanceTime(1000);
694
expect(Scheduler).toFlushAndYieldThrough(['Sibling']);
695
interrupt();
@@ -1049,18 +1006,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
1006
);
1007
expect(Scheduler).toFlushAndYield([]);
1008
expect(root).toMatchRenderedOutput(null);
1052
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
1053
- React.startTransition(() => {
1054
- root.render(
1055
- <>
1056
- <Suspense fallback={<Text text="Loading..." />}>
1057
- <AsyncText text="Async" />
1058
- <Text text="Sibling" />
1059
- </Suspense>
1060
- </>,
1061
- );
1062
- });
1063
- } else {
1009
+ React.startTransition(() => {
1010
root.render(
1011
<>
1012
<Suspense fallback={<Text text="Loading..." />}>
@@ -1069,7 +1015,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
1015
</Suspense>
1016
</>,
1017
);
1072
- }
1018
+ });
1019
expect(Scheduler).toFlushAndYieldThrough(['Suspend! [Async]', 'Sibling']);
1020
1021
await resolveText('Async');
@@ -1135,21 +1081,13 @@ describe('ReactSuspenseWithNoopRenderer', () => {
1081
ReactNoop.render(<Suspense fallback={<Text text="Loading..." />} />);
1082
expect(Scheduler).toFlushAndYield([]);
1083
1138
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
1139
- React.startTransition(() => {
1140
- ReactNoop.render(
1141
- <Suspense fallback={<Text text="Loading..." />}>
1142
- <AsyncText text="Async" />
1143
- </Suspense>,
1144
- );
1145
- });
1146
- } else {
1084
+ React.startTransition(() => {
1085
ReactNoop.render(
1086
<Suspense fallback={<Text text="Loading..." />}>
1087
<AsyncText text="Async" />
1088
</Suspense>,
1089
);
1152
- }
1090
+ });
1091
expect(Scheduler).toFlushAndYield(['Suspend! [Async]', 'Loading...']);
1092
expect(ReactNoop).toMatchRenderedOutput(null);
1093
@@ -1954,13 +1892,9 @@ describe('ReactSuspenseWithNoopRenderer', () => {
1892
ReactNoop.render(<Foo />);
1893
expect(Scheduler).toFlushAndYield(['Foo']);
1894
1957
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
1958
- React.startTransition(() => {
1959
- ReactNoop.render(<Foo renderContent={true} />);
1960
- });
1961
- } else {
1895
+ React.startTransition(() => {
1896
ReactNoop.render(<Foo renderContent={true} />);
1963
- }
1897
+ });
1898
Scheduler.unstable_advanceTime(100);
1899
await advanceTimers(100);
1900
// Start rendering
@@ -1989,22 +1923,14 @@ describe('ReactSuspenseWithNoopRenderer', () => {
1923
await advanceTimers(500);
1924
// No need to rerender.
1925
expect(Scheduler).toFlushWithoutYielding();
1992
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
1993
- // Since this is a transition, we never fallback.
1994
- expect(ReactNoop).toMatchRenderedOutput(null);
1995
- } else {
1996
- expect(ReactNoop).toMatchRenderedOutput(<span prop="Loading..." />);
1997
- }
1926
+ // Since this is a transition, we never fallback.
1927
+ expect(ReactNoop).toMatchRenderedOutput(null);
1928
1929
// Flush the promise completely
1930
await resolveText('A');
1931
// Renders successfully
2002
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
2003
- // TODO: Why does this render Foo
2004
- expect(Scheduler).toFlushAndYield(['Foo', 'A']);
2005
- } else {
2006
- expect(Scheduler).toFlushAndYield(['A']);
2007
- }
1932
+ // TODO: Why does this render Foo
1933
+ expect(Scheduler).toFlushAndYield(['Foo', 'A']);
1934
expect(ReactNoop).toMatchRenderedOutput(<span prop="A" />);
1935
});
1936
@@ -2138,13 +2064,9 @@ describe('ReactSuspenseWithNoopRenderer', () => {
2064
ReactNoop.render(<Foo />);
2065
expect(Scheduler).toFlushAndYield(['Foo']);
2066
2141
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
2142
- React.startTransition(() => {
2143
- ReactNoop.render(<Foo renderContent={true} />);
2144
- });
2145
- } else {
2067
+ React.startTransition(() => {
2068
ReactNoop.render(<Foo renderContent={true} />);
2147
- }
2069
+ });
2070
expect(Scheduler).toFlushAndYieldThrough(['Foo']);
2071
2072
// Advance some time.
@@ -2169,12 +2091,8 @@ describe('ReactSuspenseWithNoopRenderer', () => {
2091
// updates as way earlier in the past. This test ensures that we don't
2092
// use this assumption to add a very long JND.
2093
expect(Scheduler).toFlushWithoutYielding();
2172
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
2173
- // Transitions never fallback.
2174
- expect(ReactNoop).toMatchRenderedOutput(null);
2175
- } else {
2176
- expect(ReactNoop).toMatchRenderedOutput(<span prop="Loading..." />);
2177
- }
2094
+ // Transitions never fallback.
2095
+ expect(ReactNoop).toMatchRenderedOutput(null);
2096
});
2097
2098
// TODO: flip to "warns" when this is implemented again.
@@ -2542,13 +2460,9 @@ describe('ReactSuspenseWithNoopRenderer', () => {
2460
expect(Scheduler).toFlushAndYield(['Foo', 'A']);
2461
expect(ReactNoop).toMatchRenderedOutput(<span prop="A" />);
2462
2545
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
2546
- React.startTransition(() => {
2547
- ReactNoop.render(<Foo showB={true} />);
2548
- });
2549
- } else {
2463
+ React.startTransition(() => {
2464
ReactNoop.render(<Foo showB={true} />);
2551
- }
2465
+ });
2466
2467
expect(Scheduler).toFlushAndYield([
2468
'Foo',
@@ -2563,17 +2477,8 @@ describe('ReactSuspenseWithNoopRenderer', () => {
2477
Scheduler.unstable_advanceTime(600);
2478
await advanceTimers(600);
2479
2566
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
2567
- // Transitions never fall back.
2568
- expect(ReactNoop).toMatchRenderedOutput(<span prop="A" />);
2569
- } else {
2570
- expect(ReactNoop).toMatchRenderedOutput(
2571
- <>
2572
- <span prop="A" />
2573
- <span prop="Loading B..." />
2574
- </>,
2575
- );
2576
- }
2480
+ // Transitions never fall back.
2481
+ expect(ReactNoop).toMatchRenderedOutput(<span prop="A" />);
2482
});
2483
2484
// @gate enableLegacyCache
@@ -2598,13 +2503,9 @@ describe('ReactSuspenseWithNoopRenderer', () => {
2503
expect(Scheduler).toFlushAndYield(['Foo', 'A']);
2504
expect(ReactNoop).toMatchRenderedOutput(<span prop="A" />);
2505
2601
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
2602
- React.startTransition(() => {
2603
- ReactNoop.render(<Foo showB={true} />);
2604
- });
2605
- } else {
2506
+ React.startTransition(() => {
2507
ReactNoop.render(<Foo showB={true} />);
2607
- }
2508
+ });
2509
2510
expect(Scheduler).toFlushAndYield([
2511
'Foo',
@@ -2619,12 +2520,8 @@ describe('ReactSuspenseWithNoopRenderer', () => {
2520
Scheduler.unstable_advanceTime(600);
2521
await advanceTimers(600);
2522
2622
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
2623
- // Transitions never fall back.
2624
- expect(ReactNoop).toMatchRenderedOutput(<span prop="A" />);
2625
- } else {
2626
- expect(ReactNoop).toMatchRenderedOutput(<span prop="A" />);
2627
- }
2523
+ // Transitions never fall back.
2524
+ expect(ReactNoop).toMatchRenderedOutput(<span prop="A" />);
2525
});
2526
2527
// @gate enableLegacyCache
@@ -3160,26 +3057,18 @@ describe('ReactSuspenseWithNoopRenderer', () => {
3057
await act(async () => {
3058
// Update. Since showing a fallback would hide content that's already
3059
// visible, it should suspend for a JND without committing.
3163
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
3164
- React.startTransition(() => {
3165
- root.render(<App text="First update" />);
3166
- });
3167
- } else {
3060
+ React.startTransition(() => {
3061
root.render(<App text="First update" />);
3169
- }
3062
+ });
3063
expect(Scheduler).toFlushAndYield(['Suspend! [First update]']);
3064
3065
// Should not display a fallback
3066
expect(root).toMatchRenderedOutput(<span prop="Initial" />);
3067
3068
// Update again. This should also suspend for a JND.
3176
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
3177
- React.startTransition(() => {
3178
- root.render(<App text="Second update" />);
3179
- });
3180
- } else {
3069
+ React.startTransition(() => {
3070
root.render(<App text="Second update" />);
3182
- }
3071
+ });
3072
expect(Scheduler).toFlushAndYield(['Suspend! [Second update]']);
3073
3074
// Should not display a fallback
@@ -3951,117 +3840,6 @@ describe('ReactSuspenseWithNoopRenderer', () => {
3840
);
3841
});
3842
3954
- // @gate enableLegacyCache
3955
- // @gate !enableSyncDefaultUpdates
3956
- it('regression: ping at high priority causes update to be dropped', async () => {
3957
- const {useState, useTransition} = React;
3958
-
3959
- let setTextA;
3960
- function A() {
3961
- const [textA, _setTextA] = useState('A');
3962
- setTextA = _setTextA;
3963
- return (
3964
- <Suspense fallback={<Text text="Loading..." />}>
3965
- <AsyncText text={textA} />
3966
- </Suspense>
3967
- );
3968
- }
3969
-
3970
- let setTextB;
3971
- let startTransition;
3972
- function B() {
3973
- const [textB, _setTextB] = useState('B');
3974
- // eslint-disable-next-line no-unused-vars
3975
- const [_, _startTransition] = useTransition();
3976
- startTransition = _startTransition;
3977
- setTextB = _setTextB;
3978
- return (
3979
- <Suspense fallback={<Text text="Loading..." />}>
3980
- <AsyncText text={textB} />
3981
- </Suspense>
3982
- );
3983
- }
3984
-
3985
- function App() {
3986
- return (
3987
- <>
3988
- <A />
3989
- <B />
3990
- </>
3991
- );
3992
- }
3993
-
3994
- const root = ReactNoop.createRoot();
3995
- await act(async () => {
3996
- await seedNextTextCache('A');
3997
- await seedNextTextCache('B');
3998
- root.render(<App />);
3999
- });
4000
- expect(Scheduler).toHaveYielded(['A', 'B']);
4001
- expect(root).toMatchRenderedOutput(
4002
- <>
4003
- <span prop="A" />
4004
- <span prop="B" />
4005
- </>,
4006
- );
4007
-
4008
- await act(async () => {
4009
- // Triggers suspense at normal pri
4010
- setTextA('A1');
4011
- // Triggers in an unrelated tree at a different pri
4012
- startTransition(() => {
4013
- // Update A again so that it doesn't suspend on A1. That way we can ping
4014
- // the A1 update without also pinging this one. This is a workaround
4015
- // because there's currently no way to render at a lower priority (B2)
4016
- // without including all updates at higher priority (A1).
4017
- setTextA('A2');
4018
- setTextB('B2');
4019
- });
4020
-
4021
- expect(Scheduler).toFlushAndYield([
4022
- 'B',
4023
- 'Suspend! [A1]',
4024
- 'Loading...',
4025
-
4026
- 'Suspend! [A2]',
4027
- 'Loading...',
4028
- 'Suspend! [B2]',
4029
- 'Loading...',
4030
- ]);
4031
- expect(root).toMatchRenderedOutput(
4032
- <>
4033
- <span prop="A" />
4034
- <span prop="B" />
4035
- </>,
4036
- );
4037
-
4038
- await resolveText('A1');
4039
- expect(Scheduler).toFlushAndYield([
4040
- 'A1',
4041
- 'Suspend! [A2]',
4042
- 'Loading...',
4043
- 'Suspend! [B2]',
4044
- 'Loading...',
4045
- ]);
4046
- expect(root).toMatchRenderedOutput(
4047
- <>
4048
- <span prop="A1" />
4049
- <span prop="B" />
4050
- </>,
4051
- );
4052
-
4053
- await resolveText('A2');
4054
- await resolveText('B2');
4055
- });
4056
- expect(Scheduler).toHaveYielded(['A2', 'B2']);
4057
- expect(root).toMatchRenderedOutput(
4058
- <>
4059
- <span prop="A2" />
4060
- <span prop="B2" />
4061
- </>,
4062
- );
4063
- });
4064
-
3843
// Regression: https://github.com/facebook/react/issues/18486
3844
// @gate enableLegacyCache
3845
it('does not get stuck in pending state with render phase updates', async () => {
packages/react-reconciler/src/__tests__/useMutableSource-test.internal.js
+29
-172
@@ -215,27 +215,7 @@ describe('useMutableSource', () => {
215
const mutableSource = createMutableSource(source, param => param.version);
216
217
act(() => {
218
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
219
- React.startTransition(() => {
220
- ReactNoop.render(
221
- <>
222
- <Component
223
- label="a"
224
- getSnapshot={defaultGetSnapshot}
225
- mutableSource={mutableSource}
226
- subscribe={defaultSubscribe}
227
- />
228
- <Component
229
- label="b"
230
- getSnapshot={defaultGetSnapshot}
231
- mutableSource={mutableSource}
232
- subscribe={defaultSubscribe}
233
- />
234
- </>,
235
- () => Scheduler.unstable_yieldValue('Sync effect'),
236
- );
237
- });
238
- } else {
218
+ React.startTransition(() => {
219
ReactNoop.render(
220
<>
221
<Component
@@ -253,7 +233,7 @@ describe('useMutableSource', () => {
233
</>,
234
() => Scheduler.unstable_yieldValue('Sync effect'),
235
);
256
- }
236
+ });
237
// Do enough work to read from one component
238
expect(Scheduler).toFlushAndYieldThrough(['a:one']);
239
@@ -454,13 +434,9 @@ describe('useMutableSource', () => {
434
435
// Changing values should schedule an update with React.
436
// Start working on this update but don't finish it.
457
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
458
- React.startTransition(() => {
459
- source.value = 'two';
460
- });
461
- } else {
437
+ React.startTransition(() => {
438
source.value = 'two';
463
- }
439
+ });
440
expect(Scheduler).toFlushAndYieldThrough(['a:two']);
441
442
// Re-renders that occur before the update is processed
@@ -724,33 +700,7 @@ describe('useMutableSource', () => {
700
701
// Because the store has not changed yet, there are no pending updates,
702
// so it is considered safe to read from when we start this render.
727
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
728
- React.startTransition(() => {
729
- ReactNoop.render(
730
- <>
731
- <Component
732
- label="a"
733
- getSnapshot={getSnapshotA}
734
- mutableSource={mutableSource}
735
- subscribe={subscribeA}
736
- />
737
- <Component
738
- label="b"
739
- getSnapshot={getSnapshotB}
740
- mutableSource={mutableSource}
741
- subscribe={subscribeB}
742
- />
743
- <Component
744
- label="c"
745
- getSnapshot={getSnapshotB}
746
- mutableSource={mutableSource}
747
- subscribe={subscribeB}
748
- />
749
- </>,
750
- () => Scheduler.unstable_yieldValue('Sync effect'),
751
- );
752
- });
753
- } else {
703
+ React.startTransition(() => {
704
ReactNoop.render(
705
<>
706
<Component
@@ -774,7 +724,7 @@ describe('useMutableSource', () => {
724
</>,
725
() => Scheduler.unstable_yieldValue('Sync effect'),
726
);
777
- }
727
+ });
728
expect(Scheduler).toFlushAndYieldThrough(['a:a:one', 'b:b:one']);
729
730
// Mutating the source should trigger a tear detection on the next read,
@@ -865,26 +815,7 @@ describe('useMutableSource', () => {
815
816
act(() => {
817
// Start a render that uses the mutable source.
868
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
869
- React.startTransition(() => {
870
- ReactNoop.render(
871
- <>
872
- <Component
873
- label="a"
874
- getSnapshot={defaultGetSnapshot}
875
- mutableSource={mutableSource}
876
- subscribe={defaultSubscribe}
877
- />
878
- <Component
879
- label="b"
880
- getSnapshot={defaultGetSnapshot}
881
- mutableSource={mutableSource}
882
- subscribe={defaultSubscribe}
883
- />
884
- </>,
885
- );
886
- });
887
- } else {
818
+ React.startTransition(() => {
819
ReactNoop.render(
820
<>
821
<Component
@@ -901,7 +832,7 @@ describe('useMutableSource', () => {
832
/>
833
</>,
834
);
904
- }
835
+ });
836
expect(Scheduler).toFlushAndYieldThrough(['a:one']);
837
838
// Mutate source
@@ -1535,17 +1466,7 @@ describe('useMutableSource', () => {
1466
expect(root).toMatchRenderedOutput('a0');
1467
1468
await act(async () => {
1538
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
1539
- React.startTransition(() => {
1540
- root.render(
1541
- <>
1542
- <Read getSnapshot={getSnapshotA} />
1543
- <Read getSnapshot={getSnapshotB} />
1544
- <Text text="c" />
1545
- </>,
1546
- );
1547
- });
1548
- } else {
1469
+ React.startTransition(() => {
1470
root.render(
1471
<>
1472
<Read getSnapshot={getSnapshotA} />
@@ -1553,7 +1474,7 @@ describe('useMutableSource', () => {
1474
<Text text="c" />
1475
</>,
1476
);
1556
- }
1477
+ });
1478
1479
expect(Scheduler).toFlushAndYieldThrough(['a0', 'b0']);
1480
// Mutate in an event. This schedules a subscription update on a, which
@@ -1689,13 +1610,9 @@ describe('useMutableSource', () => {
1610
1611
await act(async () => {
1612
// Switch the parent and the child to read using the same config
1692
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
1693
- React.startTransition(() => {
1694
- root.render(<App parentConfig={configB} childConfig={configB} />);
1695
- });
1696
- } else {
1613
+ React.startTransition(() => {
1614
root.render(<App parentConfig={configB} childConfig={configB} />);
1698
- }
1615
+ });
1616
// Start rendering the parent, but yield before rendering the child
1617
expect(Scheduler).toFlushAndYieldThrough(['Parent: 2']);
1618
@@ -1706,41 +1623,19 @@ describe('useMutableSource', () => {
1623
source.valueB = '3';
1624
});
1625
1709
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
1710
- // In default sync mode, all of the updates flush sync.
1711
- expect(Scheduler).toFlushAndYieldThrough([
1712
- // The partial render completes
1713
- 'Child: 2',
1714
- 'Commit: 2, 2',
1715
- 'Parent: 3',
1716
- 'Child: 3',
1717
- ]);
1718
-
1719
- expect(Scheduler).toFlushAndYield([
1720
- // Now finish the rest of the update
1721
- 'Commit: 3, 3',
1722
- ]);
1723
- } else {
1724
- expect(Scheduler).toFlushAndYieldThrough([
1725
- // The partial render completes
1726
- 'Child: 2',
1727
- 'Commit: 2, 2',
1728
- ]);
1729
-
1730
- // Now there are two pending mutations at different priorities. But they
1731
- // both read the same version of the mutable source, so we must render
1732
- // them simultaneously.
1733
- //
1734
- expect(Scheduler).toFlushAndYieldThrough([
1735
- 'Parent: 3',
1736
- // Demonstrates that we can yield here
1737
- ]);
1738
- expect(Scheduler).toFlushAndYield([
1739
- // Now finish the rest of the update
1740
- 'Child: 3',
1741
- 'Commit: 3, 3',
1742
- ]);
1743
- }
1626
+ // In default sync mode, all of the updates flush sync.
1627
+ expect(Scheduler).toFlushAndYieldThrough([
1628
+ // The partial render completes
1629
+ 'Child: 2',
1630
+ 'Commit: 2, 2',
1631
+ 'Parent: 3',
1632
+ 'Child: 3',
1633
+ ]);
1634
+
1635
+ expect(Scheduler).toFlushAndYield([
1636
+ // Now finish the rest of the update
1637
+ 'Commit: 3, 3',
1638
+ ]);
1639
});
1640
});
1641
@@ -1860,26 +1755,7 @@ describe('useMutableSource', () => {
1755
1756
act(() => {
1757
// Start a render that uses the mutable source.
1863
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
1864
- React.startTransition(() => {
1865
- ReactNoop.render(
1866
- <>
1867
- <Component
1868
- label="a"
1869
- getSnapshot={defaultGetSnapshot}
1870
- mutableSource={mutableSource}
1871
- subscribe={defaultSubscribe}
1872
- />
1873
- <Component
1874
- label="b"
1875
- getSnapshot={defaultGetSnapshot}
1876
- mutableSource={mutableSource}
1877
- subscribe={defaultSubscribe}
1878
- />
1879
- </>,
1880
- );
1881
- });
1882
- } else {
1758
+ React.startTransition(() => {
1759
ReactNoop.render(
1760
<>
1761
<Component
@@ -1896,7 +1772,7 @@ describe('useMutableSource', () => {
1772
/>
1773
</>,
1774
);
1899
- }
1775
+ });
1776
expect(Scheduler).toFlushAndYieldThrough(['a:one']);
1777
1778
const PrevScheduler = Scheduler;
@@ -1941,26 +1817,7 @@ describe('useMutableSource', () => {
1817
1818
act(() => {
1819
// Start a render that uses the mutable source.
1944
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
1945
- React.startTransition(() => {
1946
- ReactNoop.render(
1947
- <>
1948
- <Component
1949
- label="a"
1950
- getSnapshot={defaultGetSnapshot}
1951
- mutableSource={mutableSource}
1952
- subscribe={defaultSubscribe}
1953
- />
1954
- <Component
1955
- label="b"
1956
- getSnapshot={defaultGetSnapshot}
1957
- mutableSource={mutableSource}
1958
- subscribe={defaultSubscribe}
1959
- />
1960
- </>,
1961
- );
1962
- });
1963
- } else {
1820
+ React.startTransition(() => {
1821
ReactNoop.render(
1822
<>
1823
<Component
@@ -1977,7 +1834,7 @@ describe('useMutableSource', () => {
1834
/>
1835
</>,
1836
);
1980
- }
1837
+ });
1838
expect(Scheduler).toFlushAndYieldThrough(['a:one']);
1839
1840
const PrevScheduler = Scheduler;
packages/react-reconciler/src/__tests__/useMutableSourceHydration-test.js
+4
-22
@@ -254,23 +254,14 @@ describe('useMutableSourceHydration', () => {
254
255
expect(() => {
256
act(() => {
257
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
258
- React.startTransition(() => {
259
- ReactDOMClient.hydrateRoot(container, <TestComponent />, {
260
- mutableSources: [mutableSource],
261
- onRecoverableError(error) {
262
- Scheduler.unstable_yieldValue('Log error: ' + error.message);
263
- },
264
- });
265
- });
266
- } else {
257
+ React.startTransition(() => {
258
ReactDOMClient.hydrateRoot(container, <TestComponent />, {
259
mutableSources: [mutableSource],
260
onRecoverableError(error) {
261
Scheduler.unstable_yieldValue('Log error: ' + error.message);
262
},
263
});
273
- }
264
+ });
265
expect(Scheduler).toFlushAndYieldThrough(['a:one']);
266
source.value = 'two';
267
});
@@ -347,23 +338,14 @@ describe('useMutableSourceHydration', () => {
338
/>
339
</>
340
);
350
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
351
- React.startTransition(() => {
352
- ReactDOMClient.hydrateRoot(container, fragment, {
353
- mutableSources: [mutableSource],
354
- onRecoverableError(error) {
355
- Scheduler.unstable_yieldValue('Log error: ' + error.message);
356
- },
357
- });
358
- });
359
- } else {
341
+ React.startTransition(() => {
342
ReactDOMClient.hydrateRoot(container, fragment, {
343
mutableSources: [mutableSource],
344
onRecoverableError(error) {
345
Scheduler.unstable_yieldValue('Log error: ' + error.message);
346
},
347
});
366
- }
348
+ });
349
expect(Scheduler).toFlushAndYieldThrough(['0:a:one']);
350
source.valueB = 'b:two';
351
});
packages/react-test-renderer/src/__tests__/ReactTestRendererAsync-test.js
+4
-16
@@ -89,17 +89,11 @@ describe('ReactTestRendererAsync', () => {
89
}
90
91
let renderer;
92
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
93
- React.startTransition(() => {
94
- renderer = ReactTestRenderer.create(<Parent step={1} />, {
95
- unstable_isConcurrent: true,
96
- });
97
- });
98
- } else {
92
+ React.startTransition(() => {
93
renderer = ReactTestRenderer.create(<Parent step={1} />, {
94
unstable_isConcurrent: true,
95
});
102
- }
96
+ });
97
98
// Flush the first two siblings
99
expect(Scheduler).toFlushAndYieldThrough(['A:1', 'B:1']);
@@ -135,17 +129,11 @@ describe('ReactTestRendererAsync', () => {
129
}
130
131
let renderer;
138
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
139
- React.startTransition(() => {
140
- renderer = ReactTestRenderer.create(<Example step={1} />, {
141
- unstable_isConcurrent: true,
142
- });
143
- });
144
- } else {
132
+ React.startTransition(() => {
133
renderer = ReactTestRenderer.create(<Example step={1} />, {
134
unstable_isConcurrent: true,
135
});
148
- }
136
+ });
137
138
// Flush the some of the changes, but don't commit
139
expect(Scheduler).toFlushAndYieldThrough(['A:1']);
packages/react/src/__tests__/ReactProfiler-test.internal.js
+12
-71
@@ -196,19 +196,7 @@ describe(`onRender`, () => {
196
return null;
197
};
198
199
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
200
- React.startTransition(() => {
201
- ReactTestRenderer.create(
202
- <React.Profiler id="test" onRender={callback}>
203
- <Yield value="first" />
204
- <Yield value="last" />
205
- </React.Profiler>,
206
- {
207
- unstable_isConcurrent: true,
208
- },
209
- );
210
- });
211
- } else {
199
+ React.startTransition(() => {
200
ReactTestRenderer.create(
201
<React.Profiler id="test" onRender={callback}>
202
<Yield value="first" />
@@ -218,7 +206,7 @@ describe(`onRender`, () => {
206
unstable_isConcurrent: true,
207
},
208
);
221
- }
209
+ });
210
211
// Times are logged until a render is committed.
212
expect(Scheduler).toFlushAndYieldThrough(['first']);
@@ -744,17 +732,7 @@ describe(`onRender`, () => {
732
Scheduler.unstable_advanceTime(5); // 0 -> 5
733
734
// Render partially, but run out of time before completing.
747
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
748
- React.startTransition(() => {
749
- ReactTestRenderer.create(
750
- <React.Profiler id="test" onRender={callback}>
751
- <Yield renderTime={2} />
752
- <Yield renderTime={3} />
753
- </React.Profiler>,
754
- {unstable_isConcurrent: true},
755
- );
756
- });
757
- } else {
735
+ React.startTransition(() => {
736
ReactTestRenderer.create(
737
<React.Profiler id="test" onRender={callback}>
738
<Yield renderTime={2} />
@@ -762,7 +740,7 @@ describe(`onRender`, () => {
740
</React.Profiler>,
741
{unstable_isConcurrent: true},
742
);
765
- }
743
+ });
744
expect(Scheduler).toFlushAndYieldThrough(['Yield:2']);
745
expect(callback).toHaveBeenCalledTimes(0);
746
@@ -791,20 +769,7 @@ describe(`onRender`, () => {
769
770
// Render partially, but don't finish.
771
// This partial render should take 5ms of simulated time.
794
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
795
- React.startTransition(() => {
796
- ReactTestRenderer.create(
797
- <React.Profiler id="outer" onRender={callback}>
798
- <Yield renderTime={5} />
799
- <Yield renderTime={10} />
800
- <React.Profiler id="inner" onRender={callback}>
801
- <Yield renderTime={17} />
802
- </React.Profiler>
803
- </React.Profiler>,
804
- {unstable_isConcurrent: true},
805
- );
806
- });
807
- } else {
772
+ React.startTransition(() => {
773
ReactTestRenderer.create(
774
<React.Profiler id="outer" onRender={callback}>
775
<Yield renderTime={5} />
@@ -815,7 +780,7 @@ describe(`onRender`, () => {
780
</React.Profiler>,
781
{unstable_isConcurrent: true},
782
);
818
- }
783
+ });
784
expect(Scheduler).toFlushAndYieldThrough(['Yield:5']);
785
expect(callback).toHaveBeenCalledTimes(0);
786
@@ -857,17 +822,7 @@ describe(`onRender`, () => {
822
// Render a partially update, but don't finish.
823
// This partial render should take 10ms of simulated time.
824
let renderer;
860
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
861
- React.startTransition(() => {
862
- renderer = ReactTestRenderer.create(
863
- <React.Profiler id="test" onRender={callback}>
864
- <Yield renderTime={10} />
865
- <Yield renderTime={20} />
866
- </React.Profiler>,
867
- {unstable_isConcurrent: true},
868
- );
869
- });
870
- } else {
825
+ React.startTransition(() => {
826
renderer = ReactTestRenderer.create(
827
<React.Profiler id="test" onRender={callback}>
828
<Yield renderTime={10} />
@@ -875,7 +830,7 @@ describe(`onRender`, () => {
830
</React.Profiler>,
831
{unstable_isConcurrent: true},
832
);
878
- }
833
+ });
834
expect(Scheduler).toFlushAndYieldThrough(['Yield:10']);
835
expect(callback).toHaveBeenCalledTimes(0);
836
@@ -944,17 +899,7 @@ describe(`onRender`, () => {
899
900
// Render a partially update, but don't finish.
901
// This partial render should take 3ms of simulated time.
947
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
948
- React.startTransition(() => {
949
- renderer.update(
950
- <React.Profiler id="test" onRender={callback}>
951
- <Yield renderTime={3} />
952
- <Yield renderTime={5} />
953
- <Yield renderTime={9} />
954
- </React.Profiler>,
955
- );
956
- });
957
- } else {
902
+ React.startTransition(() => {
903
renderer.update(
904
<React.Profiler id="test" onRender={callback}>
905
<Yield renderTime={3} />
@@ -962,7 +907,7 @@ describe(`onRender`, () => {
907
<Yield renderTime={9} />
908
</React.Profiler>,
909
);
965
- }
910
+ });
911
expect(Scheduler).toFlushAndYieldThrough(['Yield:3']);
912
expect(callback).toHaveBeenCalledTimes(0);
913
@@ -1068,13 +1013,9 @@ describe(`onRender`, () => {
1013
1014
// Render a partially update, but don't finish.
1015
// This partial render will take 10ms of actual render time.
1071
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
1072
- React.startTransition(() => {
1073
- first.setState({renderTime: 10});
1074
- });
1075
- } else {
1016
+ React.startTransition(() => {
1017
first.setState({renderTime: 10});
1077
- }
1018
+ });
1019
expect(Scheduler).toFlushAndYieldThrough(['FirstComponent:10']);
1020
expect(callback).toHaveBeenCalledTimes(0);
1021
packages/react/src/__tests__/ReactProfilerDevToolsIntegration-test.internal.js
+2
-6
@@ -155,13 +155,9 @@ describe('ReactProfiler DevTools integration', () => {
155
// for updates.
156
Scheduler.unstable_advanceTime(10000);
157
// Schedule an update.
158
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
159
- React.startTransition(() => {
160
- root.update(<Text text="B" />);
161
- });
162
- } else {
158
+ React.startTransition(() => {
159
root.update(<Text text="B" />);
164
- }
160
+ });
161
162
// Update B should not instantly expire.
163
expect(Scheduler).toFlushAndYieldThrough([]);
packages/shared/ReactFeatureFlags.js
-3
@@ -135,9 +135,6 @@ export const disableLegacyContext = false;
135
136
export const enableUseRefAccessWarning = false;
137
138
-// Enables time slicing for updates that aren't wrapped in startTransition.
139
-export const enableSyncDefaultUpdates = true;
140
-
138
export const enableUnifiedSyncLane = __EXPERIMENTAL__;
139
140
// Adds an opt-in to time slicing for updates that aren't wrapped in
packages/shared/forks/ReactFeatureFlags.native-fb.js
-1
@@ -67,7 +67,6 @@ export const createRootStrictEffectsByDefault = false;
67
export const disableSchedulerTimeoutInWorkLoop = false;
68
export const enableLazyContextPropagation = false;
69
export const enableLegacyHidden = true;
70
-export const enableSyncDefaultUpdates = true;
70
export const enableUnifiedSyncLane = false;
71
export const allowConcurrentByDefault = true;
72
export const enableCustomElementPropertySupport = false;
packages/shared/forks/ReactFeatureFlags.native-oss.js
-1
@@ -58,7 +58,6 @@ export const enableUseRefAccessWarning = false;
58
export const disableSchedulerTimeoutInWorkLoop = false;
59
export const enableLazyContextPropagation = false;
60
export const enableLegacyHidden = false;
61
-export const enableSyncDefaultUpdates = true;
61
export const enableUnifiedSyncLane = false;
62
export const allowConcurrentByDefault = false;
63
export const enableCustomElementPropertySupport = false;
packages/shared/forks/ReactFeatureFlags.test-renderer.js
-1
@@ -58,7 +58,6 @@ export const enableUseRefAccessWarning = false;
58
export const disableSchedulerTimeoutInWorkLoop = false;
59
export const enableLazyContextPropagation = false;
60
export const enableLegacyHidden = false;
61
-export const enableSyncDefaultUpdates = true;
61
export const enableUnifiedSyncLane = __EXPERIMENTAL__;
62
export const allowConcurrentByDefault = false;
63
export const enableCustomElementPropertySupport = false;
packages/shared/forks/ReactFeatureFlags.test-renderer.native.js
-1
@@ -57,7 +57,6 @@ export const enableUseRefAccessWarning = false;
57
export const disableSchedulerTimeoutInWorkLoop = false;
58
export const enableLazyContextPropagation = false;
59
export const enableLegacyHidden = false;
60
-export const enableSyncDefaultUpdates = true;
60
export const enableUnifiedSyncLane = false;
61
export const allowConcurrentByDefault = true;
62
packages/shared/forks/ReactFeatureFlags.test-renderer.www.js
-1
@@ -58,7 +58,6 @@ export const enableUseRefAccessWarning = false;
58
export const disableSchedulerTimeoutInWorkLoop = false;
59
export const enableLazyContextPropagation = false;
60
export const enableLegacyHidden = false;
61
-export const enableSyncDefaultUpdates = true;
61
export const enableUnifiedSyncLane = false;
62
export const allowConcurrentByDefault = true;
63
export const enableCustomElementPropertySupport = false;
packages/shared/forks/ReactFeatureFlags.testing.js
-1
@@ -58,7 +58,6 @@ export const enableUseRefAccessWarning = false;
58
export const disableSchedulerTimeoutInWorkLoop = false;
59
export const enableLazyContextPropagation = false;
60
export const enableLegacyHidden = false;
61
-export const enableSyncDefaultUpdates = true;
61
export const enableUnifiedSyncLane = __EXPERIMENTAL__;
62
export const allowConcurrentByDefault = false;
63
export const enableCustomElementPropertySupport = false;
packages/shared/forks/ReactFeatureFlags.testing.www.js
-1
@@ -58,7 +58,6 @@ export const enableUseRefAccessWarning = false;
58
export const disableSchedulerTimeoutInWorkLoop = false;
59
export const enableLazyContextPropagation = false;
60
export const enableLegacyHidden = false;
61
-export const enableSyncDefaultUpdates = true;
61
export const enableUnifiedSyncLane = __EXPERIMENTAL__;
62
export const allowConcurrentByDefault = true;
63
export const enableCustomElementPropertySupport = false;
packages/shared/forks/ReactFeatureFlags.www-dynamic.js
-1
@@ -21,7 +21,6 @@ export const enableUseRefAccessWarning = __VARIANT__;
21
export const enableProfilerNestedUpdateScheduledHook = __VARIANT__;
22
export const disableSchedulerTimeoutInWorkLoop = __VARIANT__;
23
export const enableLazyContextPropagation = __VARIANT__;
24
-export const enableSyncDefaultUpdates = __VARIANT__;
24
export const enableUnifiedSyncLane = __VARIANT__;
25
export const enableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay =
26
__VARIANT__;
packages/shared/forks/ReactFeatureFlags.www.js
-1
@@ -28,7 +28,6 @@ export const {
28
disableNativeComponentFrames,
29
disableSchedulerTimeoutInWorkLoop,
30
enableLazyContextPropagation,
31
- enableSyncDefaultUpdates,
31
enableUnifiedSyncLane,
32
enableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay,
33
enableTransitionTracing,
packages/use-subscription/src/__tests__/useSubscription-test.js
+8
-24
@@ -331,13 +331,9 @@ describe('useSubscription', () => {
331
332
// Start React update, but don't finish
333
act(() => {
334
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
335
- React.startTransition(() => {
336
- renderer.update(<Parent observed={observableB} />);
337
- });
338
- } else {
334
+ React.startTransition(() => {
335
renderer.update(<Parent observed={observableB} />);
340
- }
336
+ });
337
338
expect(Scheduler).toFlushAndYieldThrough(['Child: b-0']);
339
expect(log).toEqual(['Parent.componentDidMount']);
@@ -439,13 +435,9 @@ describe('useSubscription', () => {
435
436
// Start React update, but don't finish
437
act(() => {
442
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
443
- React.startTransition(() => {
444
- renderer.update(<Parent observed={observableB} />);
445
- });
446
- } else {
438
+ React.startTransition(() => {
439
renderer.update(<Parent observed={observableB} />);
448
- }
440
+ });
441
expect(Scheduler).toFlushAndYieldThrough(['Child: b-0']);
442
expect(log).toEqual([]);
443
@@ -623,24 +615,16 @@ describe('useSubscription', () => {
615
// Interrupt with a second mutation "C" -> "D".
616
// This update will not be eagerly evaluated,
617
// but useSubscription() should eagerly close over the updated value to avoid tearing.
626
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
627
- React.startTransition(() => {
628
- mutate('C');
629
- });
630
- } else {
618
+ React.startTransition(() => {
619
mutate('C');
632
- }
620
+ });
621
expect(Scheduler).toFlushAndYieldThrough([
622
'render:first:C',
623
'render:second:C',
624
]);
637
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
638
- React.startTransition(() => {
639
- mutate('D');
640
- });
641
- } else {
625
+ React.startTransition(() => {
626
mutate('D');
643
- }
627
+ });
628
expect(Scheduler).toFlushAndYield(['render:first:D', 'render:second:D']);
629
630
// No more pending updates