Clean up enableSyncDefaultUpdates flag a bit (#26858)
## Overview Does a few things: - Renames `enableSyncDefaultUpdates` to `forceConcurrentByDefaultForTesting` - Changes the way it's used so it's dead-code eliminated separate from `allowConcurrentByDefault` - Deletes a bunch of the gated code The gates that are deleted are unnecessary now. We were keeping them when we originally thought we would come back to being concurrent by default. But we've shifted and now sync-by default is the desired behavior long term, so there's no need to keep all these forked tests around. I'll follow up to delete more of the forked behavior if possible. Ideally we wouldn't need this flag even if we're still using `allowConcurrentByDefault`.
Ricky committed
Jun 1, 2023 at 09:24 UTC
018c58c9c65452cff25aaf1f38f78a9b90d8e5c1
35 files changed
+316
-882
packages/react-art/src/__tests__/ReactART-test.js
+1
-1
@@ -364,7 +364,7 @@ describe('ReactART', () => {
364
expect(onClick2).toBeCalled();
365
});
366
367
- // @gate !enableSyncDefaultUpdates
367
+ // @gate forceConcurrentByDefaultForTesting
368
it('can concurrently render with a "primary" renderer while sharing context', async () => {
369
const CurrentRendererContext = React.createContext(null);
370
packages/react-dom/src/__tests__/ReactDOMNativeEventHeuristic-test.js
+3
-3
@@ -312,10 +312,10 @@ describe('ReactDOMNativeEventHeuristic-test', () => {
312
expect(container.textContent).toEqual('not hovered');
313
314
await waitFor(['hovered']);
315
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
316
- expect(container.textContent).toEqual('hovered');
317
- } else {
315
+ if (gate(flags => flags.forceConcurrentByDefaultForTesting)) {
316
expect(container.textContent).toEqual('not hovered');
317
+ } else {
318
+ expect(container.textContent).toEqual('hovered');
319
}
320
});
321
expect(container.textContent).toEqual('hovered');
packages/react-dom/src/__tests__/ReactDOMServerPartialHydration-test.internal.js
+3
-3
@@ -2036,13 +2036,13 @@ describe('ReactDOMServerPartialHydration', () => {
2036
suspend = true;
2037
2038
await act(async () => {
2039
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
2040
- await waitFor(['Before', 'After']);
2041
- } else {
2039
+ if (gate(flags => flags.forceConcurrentByDefaultForTesting)) {
2040
await waitFor(['Before']);
2041
// This took a long time to render.
2042
Scheduler.unstable_advanceTime(1000);
2043
await waitFor(['After']);
2044
+ } else {
2045
+ await waitFor(['Before', 'After']);
2046
}
2047
2048
// This will cause us to skip the second row completely.
packages/react-dom/src/events/__tests__/DOMPluginEventSystem-test.internal.js
+2
-6
@@ -1984,13 +1984,9 @@ describe('DOMPluginEventSystem', () => {
1984
log.length = 0;
1985
1986
// Increase counter
1987
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
1988
- React.startTransition(() => {
1989
- root.render(<Test counter={1} />);
1990
- });
1991
- } else {
1987
+ React.startTransition(() => {
1988
root.render(<Test counter={1} />);
1993
- }
1989
+ });
1990
// Yield before committing
1991
await waitFor(['Test']);
1992
packages/react-reconciler/src/ReactFiber.js
+7
-4
@@ -33,7 +33,7 @@ import {
33
enableProfilerTimer,
34
enableScopeAPI,
35
enableLegacyHidden,
36
- enableSyncDefaultUpdates,
36
+ forceConcurrentByDefaultForTesting,
37
allowConcurrentByDefault,
38
enableTransitionTracing,
39
enableDebugTracing,
@@ -460,10 +460,13 @@ export function createHostRootFiber(
460
}
461
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 ||
463
+ forceConcurrentByDefaultForTesting
464
+ ) {
465
+ mode |= ConcurrentUpdatesByDefaultMode;
466
+ } else if (
467
// Only for internal experiments.
466
- (allowConcurrentByDefault && concurrentUpdatesByDefaultOverride)
468
+ allowConcurrentByDefault &&
469
+ concurrentUpdatesByDefaultOverride
470
) {
471
mode |= ConcurrentUpdatesByDefaultMode;
472
}
packages/react-reconciler/src/__tests__/ReactExpiration-test.js
+62
-98
@@ -125,7 +125,22 @@ describe('ReactExpiration', () => {
125
}
126
127
it('increases priority of updates as time progresses', async () => {
128
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
128
+ if (gate(flags => flags.forceConcurrentByDefaultForTesting)) {
129
+ ReactNoop.render(<span prop="done" />);
130
+ expect(ReactNoop).toMatchRenderedOutput(null);
131
+
132
+ // Nothing has expired yet because time hasn't advanced.
133
+ flushNextRenderIfExpired();
134
+ expect(ReactNoop).toMatchRenderedOutput(null);
135
+ // Advance time a bit, but not enough to expire the low pri update.
136
+ ReactNoop.expire(4500);
137
+ flushNextRenderIfExpired();
138
+ expect(ReactNoop).toMatchRenderedOutput(null);
139
+ // Advance by another second. Now the update should expire and flush.
140
+ ReactNoop.expire(500);
141
+ flushNextRenderIfExpired();
142
+ expect(ReactNoop).toMatchRenderedOutput(<span prop="done" />);
143
+ } else {
144
ReactNoop.render(<Text text="Step 1" />);
145
React.startTransition(() => {
146
ReactNoop.render(<Text text="Step 2" />);
@@ -147,21 +162,6 @@ describe('ReactExpiration', () => {
162
ReactNoop.expire(500);
163
await unstable_waitForExpired(['Step 2']);
164
expect(ReactNoop).toMatchRenderedOutput('Step 2');
150
- } else {
151
- ReactNoop.render(<span prop="done" />);
152
- expect(ReactNoop).toMatchRenderedOutput(null);
153
-
154
- // Nothing has expired yet because time hasn't advanced.
155
- flushNextRenderIfExpired();
156
- expect(ReactNoop).toMatchRenderedOutput(null);
157
- // Advance time a bit, but not enough to expire the low pri update.
158
- ReactNoop.expire(4500);
159
- flushNextRenderIfExpired();
160
- expect(ReactNoop).toMatchRenderedOutput(null);
161
- // Advance by another second. Now the update should expire and flush.
162
- ReactNoop.expire(500);
163
- flushNextRenderIfExpired();
164
- expect(ReactNoop).toMatchRenderedOutput(<span prop="done" />);
165
}
166
});
167
@@ -187,13 +187,9 @@ describe('ReactExpiration', () => {
187
188
// First, show what happens for updates in two separate events.
189
// Schedule an update.
190
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
191
- React.startTransition(() => {
192
- ReactNoop.render(<TextClass text="A" />);
193
- });
194
- } else {
190
+ React.startTransition(() => {
191
ReactNoop.render(<TextClass text="A" />);
196
- }
192
+ });
193
// Advance the timer.
194
Scheduler.unstable_advanceTime(2000);
195
// Partially flush the first update, then interrupt it.
@@ -248,13 +244,10 @@ describe('ReactExpiration', () => {
244
245
// First, show what happens for updates in two separate events.
246
// Schedule an update.
251
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
252
- React.startTransition(() => {
253
- ReactNoop.render(<TextClass text="A" />);
254
- });
255
- } else {
247
+ React.startTransition(() => {
248
ReactNoop.render(<TextClass text="A" />);
257
- }
249
+ });
250
+
251
// Advance the timer.
252
Scheduler.unstable_advanceTime(2000);
253
// Partially flush the first update, then interrupt it.
@@ -320,13 +313,10 @@ describe('ReactExpiration', () => {
313
}
314
315
// Initial mount
323
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
324
- React.startTransition(() => {
325
- ReactNoop.render(<App />);
326
- });
327
- } else {
316
+ React.startTransition(() => {
317
ReactNoop.render(<App />);
329
- }
318
+ });
319
+
320
await waitForAll([
321
'initial [A] [render]',
322
'initial [B] [render]',
@@ -339,13 +329,10 @@ describe('ReactExpiration', () => {
329
]);
330
331
// Partial update
342
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
343
- React.startTransition(() => {
344
- subscribers.forEach(s => s.setState({text: '1'}));
345
- });
346
- } else {
332
+ React.startTransition(() => {
333
subscribers.forEach(s => s.setState({text: '1'}));
348
- }
334
+ });
335
+
336
await waitFor(['1 [A] [render]', '1 [B] [render]']);
337
338
// Before the update can finish, update again. Even though no time has
@@ -371,13 +358,9 @@ describe('ReactExpiration', () => {
358
);
359
}
360
374
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
375
- React.startTransition(() => {
376
- root.render(<App />);
377
- });
378
- } else {
361
+ React.startTransition(() => {
362
root.render(<App />);
380
- }
363
+ });
364
365
await waitFor(['A']);
366
await waitFor(['B']);
@@ -404,13 +387,9 @@ describe('ReactExpiration', () => {
387
</>
388
);
389
}
407
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
408
- React.startTransition(() => {
409
- root.render(<App />);
410
- });
411
- } else {
390
+ React.startTransition(() => {
391
root.render(<App />);
413
- }
392
+ });
393
394
await waitFor(['A']);
395
await waitFor(['B']);
@@ -429,7 +408,26 @@ describe('ReactExpiration', () => {
408
jest.resetModules();
409
Scheduler = require('scheduler');
410
432
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
411
+ if (gate(flags => flags.forceConcurrentByDefaultForTesting)) {
412
+ // Before importing the renderer, advance the current time by a number
413
+ // larger than the maximum allowed for bitwise operations.
414
+ const maxSigned31BitInt = 1073741823;
415
+ Scheduler.unstable_advanceTime(maxSigned31BitInt * 100);
416
+ // Now import the renderer. On module initialization, it will read the
417
+ // current time.
418
+ ReactNoop = require('react-noop-renderer');
419
+ ReactNoop.render('Hi');
420
+
421
+ // The update should not have expired yet.
422
+ flushNextRenderIfExpired();
423
+ await waitFor([]);
424
+ expect(ReactNoop).toMatchRenderedOutput(null);
425
+ // Advance the time some more to expire the update.
426
+ Scheduler.unstable_advanceTime(10000);
427
+ flushNextRenderIfExpired();
428
+ await waitFor([]);
429
+ expect(ReactNoop).toMatchRenderedOutput('Hi');
430
+ } else {
431
const InternalTestUtils = require('internal-test-utils');
432
waitFor = InternalTestUtils.waitFor;
433
assertLog = InternalTestUtils.assertLog;
@@ -446,14 +444,10 @@ describe('ReactExpiration', () => {
444
React = require('react');
445
446
ReactNoop.render(<Text text="Step 1" />);
449
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
450
- React.startTransition(() => {
451
- ReactNoop.render(<Text text="Step 2" />);
452
- });
453
- await waitFor(['Step 1']);
454
- } else {
455
- ReactNoop.render('Hi');
456
- }
447
+ React.startTransition(() => {
448
+ ReactNoop.render(<Text text="Step 2" />);
449
+ });
450
+ await waitFor(['Step 1']);
451
452
// The update should not have expired yet.
453
await unstable_waitForExpired([]);
@@ -464,25 +458,6 @@ describe('ReactExpiration', () => {
458
Scheduler.unstable_advanceTime(10000);
459
await unstable_waitForExpired(['Step 2']);
460
expect(ReactNoop).toMatchRenderedOutput('Step 2');
467
- } else {
468
- // Before importing the renderer, advance the current time by a number
469
- // larger than the maximum allowed for bitwise operations.
470
- const maxSigned31BitInt = 1073741823;
471
- Scheduler.unstable_advanceTime(maxSigned31BitInt * 100);
472
- // Now import the renderer. On module initialization, it will read the
473
- // current time.
474
- ReactNoop = require('react-noop-renderer');
475
- ReactNoop.render('Hi');
476
-
477
- // The update should not have expired yet.
478
- flushNextRenderIfExpired();
479
- await waitFor([]);
480
- expect(ReactNoop).toMatchRenderedOutput(null);
481
- // Advance the time some more to expire the update.
482
- Scheduler.unstable_advanceTime(10000);
483
- flushNextRenderIfExpired();
484
- await waitFor([]);
485
- expect(ReactNoop).toMatchRenderedOutput('Hi');
461
}
462
});
463
@@ -494,13 +469,10 @@ describe('ReactExpiration', () => {
469
// Before scheduling an update, advance the current time.
470
Scheduler.unstable_advanceTime(10000);
471
497
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
498
- React.startTransition(() => {
499
- ReactNoop.render('Hi');
500
- });
501
- } else {
472
+ React.startTransition(() => {
473
ReactNoop.render('Hi');
503
- }
474
+ });
475
+
476
await unstable_waitForExpired([]);
477
expect(ReactNoop).toMatchRenderedOutput(null);
478
@@ -541,13 +513,9 @@ describe('ReactExpiration', () => {
513
514
// First demonstrate what happens when there's no starvation
515
await act(async () => {
544
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
545
- React.startTransition(() => {
546
- updateNormalPri();
547
- });
548
- } else {
516
+ React.startTransition(() => {
517
updateNormalPri();
550
- }
518
+ });
519
await waitFor(['Sync pri: 0']);
520
updateSyncPri();
521
assertLog(['Sync pri: 1', 'Normal pri: 0']);
@@ -565,13 +533,9 @@ describe('ReactExpiration', () => {
533
534
// Do the same thing, but starve the first update
535
await act(async () => {
568
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
569
- React.startTransition(() => {
570
- updateNormalPri();
571
- });
572
- } else {
536
+ React.startTransition(() => {
537
updateNormalPri();
574
- }
538
+ });
539
await waitFor(['Sync pri: 1']);
540
541
// This time, a lot of time has elapsed since the normal pri update
packages/react-reconciler/src/__tests__/ReactFlushSync-test.js
+2
-6
@@ -49,13 +49,9 @@ describe('ReactFlushSync', () => {
49
50
const root = ReactNoop.createRoot();
51
await act(async () => {
52
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
53
- React.startTransition(() => {
54
- root.render(<App />);
55
- });
56
- } else {
52
+ React.startTransition(() => {
53
root.render(<App />);
58
- }
54
+ });
55
// This will yield right before the passive effect fires
56
await waitForPaint(['0, 0']);
57
packages/react-reconciler/src/__tests__/ReactHooksWithNoopRenderer-test.js
+20
-33
@@ -179,15 +179,10 @@ describe('ReactHooksWithNoopRenderer', () => {
179
180
// Schedule some updates
181
await act(async () => {
182
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
183
- React.startTransition(() => {
184
- counter.current.updateCount(1);
185
- counter.current.updateCount(count => count + 10);
186
- });
187
- } else {
182
+ React.startTransition(() => {
183
counter.current.updateCount(1);
184
counter.current.updateCount(count => count + 10);
190
- }
185
+ });
186
187
// Partially flush without committing
188
await waitFor(['Count: 11']);
@@ -800,13 +795,9 @@ describe('ReactHooksWithNoopRenderer', () => {
795
ReactNoop.discreteUpdates(() => {
796
setRow(5);
797
});
803
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
804
- React.startTransition(() => {
805
- setRow(20);
806
- });
807
- } else {
798
+ React.startTransition(() => {
799
setRow(20);
809
- }
800
+ });
801
});
802
assertLog(['Up', 'Down']);
803
expect(root).toMatchRenderedOutput(<span prop="Down" />);
@@ -1318,13 +1309,9 @@ describe('ReactHooksWithNoopRenderer', () => {
1309
]);
1310
1311
// Schedule another update for children, and partially process it.
1321
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
1322
- React.startTransition(() => {
1323
- setChildStates.forEach(setChildState => setChildState(2));
1324
- });
1325
- } else {
1312
+ React.startTransition(() => {
1313
setChildStates.forEach(setChildState => setChildState(2));
1327
- }
1314
+ });
1315
await waitFor(['Child one render']);
1316
1317
// Schedule unmount for the parent that unmounts children with pending update.
@@ -1598,29 +1585,21 @@ describe('ReactHooksWithNoopRenderer', () => {
1585
expect(ReactNoop).toMatchRenderedOutput(<span prop="Count: (empty)" />);
1586
1587
// Rendering again should flush the previous commit's effects
1601
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
1588
+ if (gate(flags => flags.forceConcurrentByDefaultForTesting)) {
1589
+ ReactNoop.render(<Counter count={1} />, () =>
1590
+ Scheduler.log('Sync effect'),
1591
+ );
1592
+ } else {
1593
React.startTransition(() => {
1594
ReactNoop.render(<Counter count={1} />, () =>
1595
Scheduler.log('Sync effect'),
1596
);
1597
});
1607
- } else {
1608
- ReactNoop.render(<Counter count={1} />, () =>
1609
- Scheduler.log('Sync effect'),
1610
- );
1598
}
1599
1600
await waitFor(['Schedule update [0]', 'Count: 0']);
1601
1615
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
1616
- expect(ReactNoop).toMatchRenderedOutput(<span prop="Count: 0" />);
1617
- await waitFor([
1618
- 'Count: 0',
1619
- 'Sync effect',
1620
- 'Schedule update [1]',
1621
- 'Count: 1',
1622
- ]);
1623
- } else {
1602
+ if (gate(flags => flags.forceConcurrentByDefaultForTesting)) {
1603
expect(ReactNoop).toMatchRenderedOutput(
1604
<span prop="Count: (empty)" />,
1605
);
@@ -1630,6 +1609,14 @@ describe('ReactHooksWithNoopRenderer', () => {
1609
ReactNoop.flushPassiveEffects();
1610
assertLog(['Schedule update [1]']);
1611
await waitForAll(['Count: 1']);
1612
+ } else {
1613
+ expect(ReactNoop).toMatchRenderedOutput(<span prop="Count: 0" />);
1614
+ await waitFor([
1615
+ 'Count: 0',
1616
+ 'Sync effect',
1617
+ 'Schedule update [1]',
1618
+ 'Count: 1',
1619
+ ]);
1620
}
1621
1622
expect(ReactNoop).toMatchRenderedOutput(<span prop="Count: 1" />);
packages/react-reconciler/src/__tests__/ReactIncremental-test.js
+21
-90
@@ -75,13 +75,9 @@ describe('ReactIncremental', () => {
75
return [<Bar key="a" isBar={true} />, <Bar key="b" isBar={true} />];
76
}
77
78
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
79
- React.startTransition(() => {
80
- ReactNoop.render(<Foo />, () => Scheduler.log('callback'));
81
- });
82
- } else {
78
+ React.startTransition(() => {
79
ReactNoop.render(<Foo />, () => Scheduler.log('callback'));
84
- }
80
+ });
81
// Do one step of work.
82
await waitFor(['Foo']);
83
@@ -168,26 +164,18 @@ describe('ReactIncremental', () => {
164
ReactNoop.render(<Foo text="foo" />);
165
await waitForAll(['Foo', 'Bar', 'Bar']);
166
171
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
172
- React.startTransition(() => {
173
- ReactNoop.render(<Foo text="bar" />);
174
- });
175
- } else {
167
+ React.startTransition(() => {
168
ReactNoop.render(<Foo text="bar" />);
177
- }
169
+ });
170
// Flush part of the work
171
await waitFor(['Foo', 'Bar']);
172
173
// This will abort the previous work and restart
174
ReactNoop.flushSync(() => ReactNoop.render(null));
175
184
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
185
- React.startTransition(() => {
186
- ReactNoop.render(<Foo text="baz" />);
187
- });
188
- } else {
176
+ React.startTransition(() => {
177
ReactNoop.render(<Foo text="baz" />);
190
- }
178
+ });
179
180
// Flush part of the new work
181
await waitFor(['Foo', 'Bar']);
@@ -221,17 +209,7 @@ describe('ReactIncremental', () => {
209
ReactNoop.render(<Foo />);
210
await waitForAll([]);
211
224
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
225
- React.startTransition(() => {
226
- inst.setState(
227
- () => {
228
- Scheduler.log('setState1');
229
- return {text: 'bar'};
230
- },
231
- () => Scheduler.log('callback1'),
232
- );
233
- });
234
- } else {
212
+ React.startTransition(() => {
213
inst.setState(
214
() => {
215
Scheduler.log('setState1');
@@ -239,24 +217,14 @@ describe('ReactIncremental', () => {
217
},
218
() => Scheduler.log('callback1'),
219
);
242
- }
220
+ });
221
222
// Flush part of the work
223
await waitFor(['setState1']);
224
225
// This will abort the previous work and restart
226
ReactNoop.flushSync(() => ReactNoop.render(<Foo />));
249
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
250
- React.startTransition(() => {
251
- inst.setState(
252
- () => {
253
- Scheduler.log('setState2');
254
- return {text2: 'baz'};
255
- },
256
- () => Scheduler.log('callback2'),
257
- );
258
- });
259
- } else {
227
+ React.startTransition(() => {
228
inst.setState(
229
() => {
230
Scheduler.log('setState2');
@@ -264,7 +232,7 @@ describe('ReactIncremental', () => {
232
},
233
() => Scheduler.log('callback2'),
234
);
267
- }
235
+ });
236
237
// Flush the rest of the work which now includes the low priority
238
await waitForAll(['setState1', 'setState2', 'callback1', 'callback2']);
@@ -1825,18 +1793,7 @@ describe('ReactIncremental', () => {
1793
'ShowLocale {"locale":"de"}',
1794
'ShowBoth {"locale":"de"}',
1795
]);
1828
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
1829
- React.startTransition(() => {
1830
- ReactNoop.render(
1831
- <Intl locale="sv">
1832
- <ShowLocale />
1833
- <div>
1834
- <ShowBoth />
1835
- </div>
1836
- </Intl>,
1837
- );
1838
- });
1839
- } else {
1796
+ React.startTransition(() => {
1797
ReactNoop.render(
1798
<Intl locale="sv">
1799
<ShowLocale />
@@ -1845,7 +1802,7 @@ describe('ReactIncremental', () => {
1802
</div>
1803
</Intl>,
1804
);
1848
- }
1805
+ });
1806
await waitFor(['Intl {}']);
1807
1808
ReactNoop.render(
@@ -1977,22 +1934,7 @@ describe('ReactIncremental', () => {
1934
}
1935
}
1936
1980
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
1981
- React.startTransition(() => {
1982
- ReactNoop.render(
1983
- <Intl locale="fr">
1984
- <ShowLocale />
1985
- <LegacyHiddenDiv mode="hidden">
1986
- <ShowLocale />
1987
- <Intl locale="ru">
1988
- <ShowLocale />
1989
- </Intl>
1990
- </LegacyHiddenDiv>
1991
- <ShowLocale />
1992
- </Intl>,
1993
- );
1994
- });
1995
- } else {
1937
+ React.startTransition(() => {
1938
ReactNoop.render(
1939
<Intl locale="fr">
1940
<ShowLocale />
@@ -2005,7 +1947,8 @@ describe('ReactIncremental', () => {
1947
<ShowLocale />
1948
</Intl>,
1949
);
2008
- }
1950
+ });
1951
+
1952
await waitFor([
1953
'Intl {}',
1954
'ShowLocale {"locale":"fr"}',
@@ -2682,13 +2625,9 @@ describe('ReactIncremental', () => {
2625
return null;
2626
}
2627
2685
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
2686
- React.startTransition(() => {
2687
- ReactNoop.render(<Parent step={1} />);
2688
- });
2689
- } else {
2628
+ React.startTransition(() => {
2629
ReactNoop.render(<Parent step={1} />);
2691
- }
2630
+ });
2631
await waitFor(['Parent: 1']);
2632
2633
// Interrupt at same priority
@@ -2708,13 +2647,9 @@ describe('ReactIncremental', () => {
2647
return null;
2648
}
2649
2711
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
2712
- React.startTransition(() => {
2713
- ReactNoop.render(<Parent step={1} />);
2714
- });
2715
- } else {
2650
+ React.startTransition(() => {
2651
ReactNoop.render(<Parent step={1} />);
2717
- }
2652
+ });
2653
await waitFor(['Parent: 1']);
2654
2655
// Interrupt at lower priority
@@ -2735,13 +2670,9 @@ describe('ReactIncremental', () => {
2670
return null;
2671
}
2672
2738
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
2739
- React.startTransition(() => {
2740
- ReactNoop.render(<Parent step={1} />);
2741
- });
2742
- } else {
2673
+ React.startTransition(() => {
2674
ReactNoop.render(<Parent step={1} />);
2744
- }
2675
+ });
2676
await waitFor(['Parent: 1']);
2677
2678
// Interrupt at higher priority
packages/react-reconciler/src/__tests__/ReactIncrementalErrorHandling-test.internal.js
+14
-78
@@ -97,25 +97,7 @@ describe('ReactIncrementalErrorHandling', () => {
97
throw new Error('oops!');
98
}
99
100
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
101
- React.startTransition(() => {
102
- ReactNoop.render(
103
- <>
104
- <ErrorBoundary>
105
- <Indirection>
106
- <Indirection>
107
- <Indirection>
108
- <BadRender />
109
- </Indirection>
110
- </Indirection>
111
- </Indirection>
112
- </ErrorBoundary>
113
- <Indirection />
114
- <Indirection />
115
- </>,
116
- );
117
- });
118
- } else {
100
+ React.startTransition(() => {
101
ReactNoop.render(
102
<>
103
<ErrorBoundary>
@@ -131,7 +113,7 @@ describe('ReactIncrementalErrorHandling', () => {
113
<Indirection />
114
</>,
115
);
134
- }
116
+ });
117
118
// Start rendering asynchronously
119
await waitFor([
@@ -214,25 +196,7 @@ describe('ReactIncrementalErrorHandling', () => {
196
throw new Error('oops!');
197
}
198
217
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
218
- React.startTransition(() => {
219
- ReactNoop.render(
220
- <>
221
- <ErrorBoundary>
222
- <Indirection>
223
- <Indirection>
224
- <Indirection>
225
- <BadRender />
226
- </Indirection>
227
- </Indirection>
228
- </Indirection>
229
- </ErrorBoundary>
230
- <Indirection />
231
- <Indirection />
232
- </>,
233
- );
234
- });
235
- } else {
199
+ React.startTransition(() => {
200
ReactNoop.render(
201
<>
202
<ErrorBoundary>
@@ -248,7 +212,7 @@ describe('ReactIncrementalErrorHandling', () => {
212
<Indirection />
213
</>,
214
);
251
- }
215
+ });
216
217
// Start rendering asynchronously
218
await waitFor([
@@ -416,13 +380,9 @@ describe('ReactIncrementalErrorHandling', () => {
380
);
381
}
382
419
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
420
- React.startTransition(() => {
421
- ReactNoop.render(<Parent />, () => Scheduler.log('commit'));
422
- });
423
- } else {
383
+ React.startTransition(() => {
384
ReactNoop.render(<Parent />, () => Scheduler.log('commit'));
425
- }
385
+ });
386
387
// Render the bad component asynchronously
388
await waitFor(['Parent', 'BadRender']);
@@ -458,13 +418,9 @@ describe('ReactIncrementalErrorHandling', () => {
418
);
419
}
420
461
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
462
- React.startTransition(() => {
463
- ReactNoop.render(<App />);
464
- });
465
- } else {
421
+ React.startTransition(() => {
422
ReactNoop.render(<App />);
467
- }
423
+ });
424
425
// Render part of the tree
426
await waitFor(['A', 'B']);
@@ -595,21 +551,13 @@ describe('ReactIncrementalErrorHandling', () => {
551
throw new Error('Hello');
552
}
553
598
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
599
- React.startTransition(() => {
600
- ReactNoop.render(
601
- <ErrorBoundary>
602
- <BrokenRender />
603
- </ErrorBoundary>,
604
- );
605
- });
606
- } else {
554
+ React.startTransition(() => {
555
ReactNoop.render(
556
<ErrorBoundary>
557
<BrokenRender />
558
</ErrorBoundary>,
559
);
612
- }
560
+ });
561
562
await waitFor(['ErrorBoundary render success']);
563
expect(ReactNoop).toMatchRenderedOutput(null);
@@ -783,21 +731,13 @@ describe('ReactIncrementalErrorHandling', () => {
731
throw new Error('Hello');
732
}
733
786
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
787
- React.startTransition(() => {
788
- ReactNoop.render(
789
- <RethrowErrorBoundary>
790
- <BrokenRender />
791
- </RethrowErrorBoundary>,
792
- );
793
- });
794
- } else {
734
+ React.startTransition(() => {
735
ReactNoop.render(
736
<RethrowErrorBoundary>
737
<BrokenRender />
738
</RethrowErrorBoundary>,
739
);
800
- }
740
+ });
741
742
await waitFor(['RethrowErrorBoundary render']);
743
@@ -1856,13 +1796,9 @@ describe('ReactIncrementalErrorHandling', () => {
1796
}
1797
1798
await act(async () => {
1859
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
1860
- React.startTransition(() => {
1861
- root.render(<Oops />);
1862
- });
1863
- } else {
1799
+ React.startTransition(() => {
1800
root.render(<Oops />);
1865
- }
1801
+ });
1802
1803
// Render past the component that throws, then yield.
1804
await waitFor(['Oops']);
packages/react-reconciler/src/__tests__/ReactIncrementalReflection-test.js
+10
-30
@@ -65,13 +65,9 @@ describe('ReactIncrementalReflection', () => {
65
return <Component />;
66
}
67
68
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
69
- React.startTransition(() => {
70
- ReactNoop.render(<Foo />);
71
- });
72
- } else {
68
+ React.startTransition(() => {
69
ReactNoop.render(<Foo />);
74
- }
70
+ });
71
72
// Render part way through but don't yet commit the updates.
73
await waitFor(['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
await waitFor(['Other']);
@@ -191,13 +183,9 @@ describe('ReactIncrementalReflection', () => {
183
return [<Component key="a" step={props.step} />, <Sibling key="b" />];
184
}
185
194
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
195
- React.startTransition(() => {
196
- ReactNoop.render(<Foo step={0} />);
197
- });
198
- } else {
186
+ React.startTransition(() => {
187
ReactNoop.render(<Foo step={0} />);
200
- }
188
+ });
189
// Flush past Component but don't complete rendering everything yet.
190
await waitFor([['componentWillMount', null], 'render', 'render sibling']);
191
@@ -227,13 +215,9 @@ describe('ReactIncrementalReflection', () => {
215
216
// The next step will render a new host node but won't get committed yet.
217
// We expect this to mutate the original Fiber.
230
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
231
- React.startTransition(() => {
232
- ReactNoop.render(<Foo step={2} />);
233
- });
234
- } else {
218
+ React.startTransition(() => {
219
ReactNoop.render(<Foo step={2} />);
236
- }
220
+ });
221
await waitFor([
222
['componentWillUpdate', hostSpan],
223
'render',
@@ -254,13 +238,9 @@ describe('ReactIncrementalReflection', () => {
238
expect(ReactNoop.findInstance(classInstance)).toBe(hostDiv);
239
240
// Render to null but don't commit it yet.
257
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
258
- React.startTransition(() => {
259
- ReactNoop.render(<Foo step={3} />);
260
- });
261
- } else {
241
+ React.startTransition(() => {
242
ReactNoop.render(<Foo step={3} />);
263
- }
243
+ });
244
await waitFor([
245
['componentWillUpdate', hostDiv],
246
'render',
packages/react-reconciler/src/__tests__/ReactIncrementalScheduling-test.js
+10
-31
@@ -115,15 +115,10 @@ describe('ReactIncrementalScheduling', () => {
115
116
// Schedule deferred work in the reverse order
117
await act(async () => {
118
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
119
- React.startTransition(() => {
120
- ReactNoop.renderToRootWithID(<Text text="c:2" />, 'c');
121
- ReactNoop.renderToRootWithID(<Text text="b:2" />, 'b');
122
- });
123
- } else {
118
+ React.startTransition(() => {
119
ReactNoop.renderToRootWithID(<Text text="c:2" />, 'c');
120
ReactNoop.renderToRootWithID(<Text text="b:2" />, 'b');
126
- }
121
+ });
122
// Ensure it starts in the order it was scheduled
123
await waitFor(['c:2']);
124
@@ -132,13 +127,9 @@ describe('ReactIncrementalScheduling', () => {
127
expect(ReactNoop.getChildrenAsJSX('c')).toEqual('c:2');
128
// Schedule last bit of work, it will get processed the last
129
135
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
136
- React.startTransition(() => {
137
- ReactNoop.renderToRootWithID(<Text text="a:2" />, 'a');
138
- });
139
- } else {
130
+ React.startTransition(() => {
131
ReactNoop.renderToRootWithID(<Text text="a:2" />, 'a');
141
- }
132
+ });
133
134
// Keep performing work in the order it was scheduled
135
await waitFor(['b:2']);
@@ -189,13 +180,9 @@ describe('ReactIncrementalScheduling', () => {
180
}
181
}
182
192
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
193
- React.startTransition(() => {
194
- ReactNoop.render(<Foo />);
195
- });
196
- } else {
183
+ React.startTransition(() => {
184
ReactNoop.render(<Foo />);
198
- }
185
+ });
186
// Render without committing
187
await waitFor(['render: 0']);
188
@@ -209,13 +196,9 @@ describe('ReactIncrementalScheduling', () => {
196
'componentDidUpdate: 1',
197
]);
198
212
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
213
- React.startTransition(() => {
214
- instance.setState({tick: 2});
215
- });
216
- } else {
199
+ React.startTransition(() => {
200
instance.setState({tick: 2});
218
- }
201
+ });
202
await waitFor(['render: 2']);
203
expect(ReactNoop.flushNextYield()).toEqual([
204
'componentDidUpdate: 2',
@@ -316,13 +299,9 @@ describe('ReactIncrementalScheduling', () => {
299
return <span prop={this.state.step} />;
300
}
301
}
319
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
320
- React.startTransition(() => {
321
- ReactNoop.render(<Foo />);
322
- });
323
- } else {
302
+ React.startTransition(() => {
303
ReactNoop.render(<Foo />);
325
- }
304
+ });
305
306
// This should be just enough to complete all the work, but not enough to
307
// commit it.
packages/react-reconciler/src/__tests__/ReactIncrementalSideEffects-test.js
+8
-24
@@ -464,13 +464,9 @@ describe('ReactIncrementalSideEffects', () => {
464
</div>,
465
);
466
467
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
468
- React.startTransition(() => {
469
- ReactNoop.render(<Foo text="World" />);
470
- });
471
- } else {
467
+ React.startTransition(() => {
468
ReactNoop.render(<Foo text="World" />);
473
- }
469
+ });
470
471
// Flush some of the work without committing
472
await waitFor(['Foo', 'Bar']);
@@ -703,13 +699,9 @@ describe('ReactIncrementalSideEffects', () => {
699
Scheduler.log('Foo ' + props.step);
700
return <span prop={props.step} />;
701
}
706
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
707
- React.startTransition(() => {
708
- ReactNoop.render(<Foo step={1} />);
709
- });
710
- } else {
702
+ React.startTransition(() => {
703
ReactNoop.render(<Foo step={1} />);
712
- }
704
+ });
705
// This should be just enough to complete the tree without committing it
706
await waitFor(['Foo 1']);
707
expect(ReactNoop.getChildrenAsJSX()).toEqual(null);
@@ -718,26 +710,18 @@ describe('ReactIncrementalSideEffects', () => {
710
await waitForPaint([]);
711
expect(ReactNoop.getChildrenAsJSX()).toEqual(<span prop={1} />);
712
721
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
722
- React.startTransition(() => {
723
- ReactNoop.render(<Foo step={2} />);
724
- });
725
- } else {
713
+ React.startTransition(() => {
714
ReactNoop.render(<Foo step={2} />);
727
- }
715
+ });
716
// This should be just enough to complete the tree without committing it
717
await waitFor(['Foo 2']);
718
expect(ReactNoop.getChildrenAsJSX()).toEqual(<span prop={1} />);
719
// This time, before we commit the tree, we update the root component with
720
// new props
721
734
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
735
- React.startTransition(() => {
736
- ReactNoop.render(<Foo step={3} />);
737
- });
738
- } else {
722
+ React.startTransition(() => {
723
ReactNoop.render(<Foo step={3} />);
740
- }
724
+ });
725
expect(ReactNoop.getChildrenAsJSX()).toEqual(<span prop={1} />);
726
// Now let's commit. We already had a commit that was pending, which will
727
// render 2.
packages/react-reconciler/src/__tests__/ReactIncrementalUpdates-test.js
+34
-69
@@ -158,7 +158,9 @@ describe('ReactIncrementalUpdates', () => {
158
// Schedule some async updates
159
if (
160
gate(
161
- flags => flags.enableSyncDefaultUpdates || flags.enableUnifiedSyncLane,
161
+ flags =>
162
+ !flags.forceConcurrentByDefaultForTesting ||
163
+ flags.enableUnifiedSyncLane,
164
)
165
) {
166
React.startTransition(() => {
@@ -189,7 +191,9 @@ describe('ReactIncrementalUpdates', () => {
191
// The sync updates should have flushed, but not the async ones.
192
if (
193
gate(
192
- flags => flags.enableSyncDefaultUpdates && flags.enableUnifiedSyncLane,
194
+ flags =>
195
+ !flags.forceConcurrentByDefaultForTesting &&
196
+ flags.enableUnifiedSyncLane,
197
)
198
) {
199
assertLog(['d', 'e', 'f']);
@@ -205,7 +209,9 @@ describe('ReactIncrementalUpdates', () => {
209
// is deterministic.
210
if (
211
gate(
208
- flags => flags.enableSyncDefaultUpdates && !flags.enableUnifiedSyncLane,
212
+ flags =>
213
+ !flags.forceConcurrentByDefaultForTesting &&
214
+ !flags.enableUnifiedSyncLane,
215
)
216
) {
217
await waitForAll([
@@ -263,7 +269,9 @@ describe('ReactIncrementalUpdates', () => {
269
// Schedule some async updates
270
if (
271
gate(
266
- flags => flags.enableSyncDefaultUpdates || flags.enableUnifiedSyncLane,
272
+ flags =>
273
+ !flags.forceConcurrentByDefaultForTesting ||
274
+ flags.enableUnifiedSyncLane,
275
)
276
) {
277
React.startTransition(() => {
@@ -297,7 +305,9 @@ describe('ReactIncrementalUpdates', () => {
305
// The sync updates should have flushed, but not the async ones.
306
if (
307
gate(
300
- flags => flags.enableSyncDefaultUpdates && flags.enableUnifiedSyncLane,
308
+ flags =>
309
+ !flags.forceConcurrentByDefaultForTesting &&
310
+ flags.enableUnifiedSyncLane,
311
)
312
) {
313
assertLog(['d', 'e', 'f']);
@@ -312,7 +322,9 @@ describe('ReactIncrementalUpdates', () => {
322
// is deterministic.
323
if (
324
gate(
315
- flags => flags.enableSyncDefaultUpdates && !flags.enableUnifiedSyncLane,
325
+ flags =>
326
+ !flags.forceConcurrentByDefaultForTesting &&
327
+ !flags.enableUnifiedSyncLane,
328
)
329
) {
330
await waitForAll([
@@ -543,13 +555,9 @@ describe('ReactIncrementalUpdates', () => {
555
}
556
557
await act(async () => {
546
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
547
- React.startTransition(() => {
548
- ReactNoop.render(<App />);
549
- });
550
- } else {
558
+ React.startTransition(() => {
559
ReactNoop.render(<App />);
552
- }
560
+ });
561
assertLog([]);
562
await waitForAll([
563
'Render: 0',
@@ -560,13 +568,9 @@ describe('ReactIncrementalUpdates', () => {
568
]);
569
570
Scheduler.unstable_advanceTime(10000);
563
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
564
- React.startTransition(() => {
565
- setCount(2);
566
- });
567
- } else {
571
+ React.startTransition(() => {
572
setCount(2);
569
- }
573
+ });
574
// The transition should not have expired, so we should be able to
575
// partially render it.
576
await waitFor(['Render: 2']);
@@ -583,18 +587,7 @@ describe('ReactIncrementalUpdates', () => {
587
588
Scheduler.unstable_advanceTime(10000);
589
586
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
587
- React.startTransition(() => {
588
- ReactNoop.render(
589
- <>
590
- <Text text="A" />
591
- <Text text="B" />
592
- <Text text="C" />
593
- <Text text="D" />
594
- </>,
595
- );
596
- });
597
- } else {
590
+ React.startTransition(() => {
591
ReactNoop.render(
592
<>
593
<Text text="A" />
@@ -603,7 +596,7 @@ describe('ReactIncrementalUpdates', () => {
596
<Text text="D" />
597
</>,
598
);
606
- }
599
+ });
600
// The transition should not have expired, so we should be able to
601
// partially render it.
602
await waitFor(['A']);
@@ -612,18 +605,7 @@ describe('ReactIncrementalUpdates', () => {
605
});
606
607
it('regression: does not expire soon due to previous expired work', async () => {
615
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
616
- React.startTransition(() => {
617
- ReactNoop.render(
618
- <>
619
- <Text text="A" />
620
- <Text text="B" />
621
- <Text text="C" />
622
- <Text text="D" />
623
- </>,
624
- );
625
- });
626
- } else {
608
+ React.startTransition(() => {
609
ReactNoop.render(
610
<>
611
<Text text="A" />
@@ -632,7 +614,8 @@ describe('ReactIncrementalUpdates', () => {
614
<Text text="D" />
615
</>,
616
);
635
- }
617
+ });
618
+
619
await waitFor(['A']);
620
// This will expire the rest of the update
621
Scheduler.unstable_advanceTime(10000);
@@ -643,18 +626,7 @@ describe('ReactIncrementalUpdates', () => {
626
Scheduler.unstable_advanceTime(10000);
627
628
// Now do another transition. This one should not expire.
646
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
647
- React.startTransition(() => {
648
- ReactNoop.render(
649
- <>
650
- <Text text="A" />
651
- <Text text="B" />
652
- <Text text="C" />
653
- <Text text="D" />
654
- </>,
655
- );
656
- });
657
- } else {
629
+ React.startTransition(() => {
630
ReactNoop.render(
631
<>
632
<Text text="A" />
@@ -663,7 +635,8 @@ describe('ReactIncrementalUpdates', () => {
635
<Text text="D" />
636
</>,
637
);
666
- }
638
+ });
639
+
640
// The transition should not have expired, so we should be able to
641
// partially render it.
642
await waitFor(['A']);
@@ -703,13 +676,9 @@ describe('ReactIncrementalUpdates', () => {
676
expect(root).toMatchRenderedOutput(null);
677
678
await act(() => {
706
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
707
- React.startTransition(() => {
708
- pushToLog('A');
709
- });
710
- } else {
679
+ React.startTransition(() => {
680
pushToLog('A');
712
- }
681
+ });
682
683
ReactNoop.unstable_runWithPriority(ContinuousEventPriority, () =>
684
pushToLog('B'),
@@ -768,13 +737,9 @@ describe('ReactIncrementalUpdates', () => {
737
expect(root).toMatchRenderedOutput(null);
738
739
await act(() => {
771
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
772
- React.startTransition(() => {
773
- pushToLog('A');
774
- });
775
- } else {
740
+ React.startTransition(() => {
741
pushToLog('A');
777
- }
742
+ });
743
ReactNoop.unstable_runWithPriority(ContinuousEventPriority, () =>
744
pushToLog('B'),
745
);
packages/react-reconciler/src/__tests__/ReactInterleavedUpdates-test.js
+5
-13
@@ -65,25 +65,17 @@ describe('ReactInterleavedUpdates', () => {
65
expect(root).toMatchRenderedOutput('000');
66
67
await act(async () => {
68
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
69
- React.startTransition(() => {
70
- updateChildren(1);
71
- });
72
- } else {
68
+ React.startTransition(() => {
69
updateChildren(1);
74
- }
70
+ });
71
// Partially render the children. Only the first one.
72
await waitFor([1]);
73
74
// In an interleaved event, schedule an update on each of the children.
75
// Including the two that haven't rendered yet.
80
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
81
- React.startTransition(() => {
82
- updateChildren(2);
83
- });
84
- } else {
76
+ React.startTransition(() => {
77
updateChildren(2);
86
- }
78
+ });
79
80
// We should continue rendering without including the interleaved updates.
81
await waitForPaint([1, 1]);
@@ -94,7 +86,7 @@ describe('ReactInterleavedUpdates', () => {
86
expect(root).toMatchRenderedOutput('222');
87
});
88
97
- // @gate !enableSyncDefaultUpdates
89
+ // @gate forceConcurrentByDefaultForTesting
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.
packages/react-reconciler/src/__tests__/ReactNewContext-test.js
+4
-12
@@ -885,13 +885,9 @@ describe('ReactNewContext', () => {
885
);
886
}
887
888
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
889
- React.startTransition(() => {
890
- ReactNoop.render(<App value={1} />);
891
- });
892
- } else {
888
+ React.startTransition(() => {
889
ReactNoop.render(<App value={1} />);
894
- }
890
+ });
891
// Render past the Provider, but don't commit yet
892
await waitFor(['Foo']);
893
@@ -934,13 +930,9 @@ describe('ReactNewContext', () => {
930
);
931
}
932
937
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
938
- React.startTransition(() => {
939
- ReactNoop.render(<App value={1} />);
940
- });
941
- } else {
933
+ React.startTransition(() => {
934
ReactNoop.render(<App value={1} />);
943
- }
935
+ });
936
await waitForAll(['Foo', 'Foo']);
937
938
// Get a new copy of ReactNoop
packages/react-reconciler/src/__tests__/ReactSchedulerIntegration-test.js
+2
-6
@@ -109,13 +109,9 @@ describe('ReactSchedulerIntegration', () => {
109
scheduleCallback(NormalPriority, () => Scheduler.log('C'));
110
111
// Schedule a React render. React will request a paint after committing it.
112
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
113
- React.startTransition(() => {
114
- root.render('Update');
115
- });
116
- } else {
112
+ React.startTransition(() => {
113
root.render('Update');
118
- }
114
+ });
115
116
// Perform just a little bit of work. By now, the React task will have
117
// already been scheduled, behind A, B, and C.
packages/react-reconciler/src/__tests__/ReactSuspense-test.internal.js
+3
-15
@@ -224,19 +224,7 @@ describe('ReactSuspense', () => {
224
expect(root).toMatchRenderedOutput('Initial');
225
226
// The update will suspend.
227
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
228
- React.startTransition(() => {
229
- root.update(
230
- <>
231
- <Suspense fallback={<Text text="Loading..." />}>
232
- <Async />
233
- </Suspense>
234
- <Text text="After Suspense" />
235
- <Text text="Sibling" />
236
- </>,
237
- );
238
- });
239
- } else {
227
+ React.startTransition(() => {
228
root.update(
229
<>
230
<Suspense fallback={<Text text="Loading..." />}>
@@ -246,7 +234,7 @@ describe('ReactSuspense', () => {
234
<Text text="Sibling" />
235
</>,
236
);
249
- }
237
+ });
238
239
// Yield past the Suspense boundary but don't complete the last sibling.
240
await waitFor(['Suspend!', 'Loading...', 'After Suspense']);
@@ -339,7 +327,7 @@ describe('ReactSuspense', () => {
327
expect(root).toMatchRenderedOutput('AB');
328
});
329
342
- // @gate !enableSyncDefaultUpdates
330
+ // @gate forceConcurrentByDefaultForTesting
331
it(
332
'interrupts current render when something suspends with a ' +
333
"delay and we've already skipped over a lower priority update in " +
packages/react-reconciler/src/__tests__/ReactSuspenseList-test.js
+6
-18
@@ -2497,13 +2497,9 @@ describe('ReactSuspenseList', () => {
2497
2498
await act(async () => {
2499
// Add a few items at the end.
2500
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
2501
- React.startTransition(() => {
2502
- updateLowPri(true);
2503
- });
2504
- } else {
2500
+ React.startTransition(() => {
2501
updateLowPri(true);
2506
- }
2502
+ });
2503
2504
// Flush partially through.
2505
await waitFor(['B', 'C']);
@@ -2639,13 +2635,9 @@ describe('ReactSuspenseList', () => {
2635
);
2636
}
2637
2642
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
2643
- React.startTransition(() => {
2644
- ReactNoop.render(<App />);
2645
- });
2646
- } else {
2638
+ React.startTransition(() => {
2639
ReactNoop.render(<App />);
2648
- }
2640
+ });
2641
2642
await waitFor(['App', 'First Pass A', 'Mount A', 'A']);
2643
expect(ReactNoop).toMatchRenderedOutput(<span>A</span>);
@@ -2707,13 +2699,9 @@ describe('ReactSuspenseList', () => {
2699
);
2700
}
2701
2710
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
2711
- React.startTransition(() => {
2712
- ReactNoop.render(<App />);
2713
- });
2714
- } else {
2702
+ React.startTransition(() => {
2703
ReactNoop.render(<App />);
2716
- }
2704
+ });
2705
2706
await waitFor([
2707
'App',
packages/react-reconciler/src/__tests__/ReactSuspenseWithNoopRenderer-test.js
+19
-51
@@ -681,35 +681,23 @@ describe('ReactSuspenseWithNoopRenderer', () => {
681
682
// Schedule an update at several distinct expiration times
683
await act(async () => {
684
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
685
- React.startTransition(() => {
686
- root.render(<App step={1} shouldSuspend={true} />);
687
- });
688
- } else {
684
+ React.startTransition(() => {
685
root.render(<App step={1} shouldSuspend={true} />);
690
- }
686
+ });
687
Scheduler.unstable_advanceTime(1000);
688
await waitFor(['Sibling']);
689
interrupt();
690
695
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
696
- React.startTransition(() => {
697
- root.render(<App step={2} shouldSuspend={true} />);
698
- });
699
- } else {
691
+ React.startTransition(() => {
692
root.render(<App step={2} shouldSuspend={true} />);
701
- }
693
+ });
694
Scheduler.unstable_advanceTime(1000);
695
await waitFor(['Sibling']);
696
interrupt();
697
706
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
707
- React.startTransition(() => {
708
- root.render(<App step={3} shouldSuspend={true} />);
709
- });
710
- } else {
698
+ React.startTransition(() => {
699
root.render(<App step={3} shouldSuspend={true} />);
712
- }
700
+ });
701
Scheduler.unstable_advanceTime(1000);
702
await waitFor(['Sibling']);
703
interrupt();
@@ -865,18 +853,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
853
);
854
await waitForAll([]);
855
expect(root).toMatchRenderedOutput(null);
868
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
869
- React.startTransition(() => {
870
- root.render(
871
- <>
872
- <Suspense fallback={<Text text="Loading..." />}>
873
- <AsyncText text="Async" />
874
- <Text text="Sibling" />
875
- </Suspense>
876
- </>,
877
- );
878
- });
879
- } else {
856
+ React.startTransition(() => {
857
root.render(
858
<>
859
<Suspense fallback={<Text text="Loading..." />}>
@@ -885,7 +862,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
862
</Suspense>
863
</>,
864
);
888
- }
865
+ });
866
await waitFor(['Suspend! [Async]']);
867
868
await resolveText('Async');
@@ -2256,26 +2233,26 @@ describe('ReactSuspenseWithNoopRenderer', () => {
2233
await waitForAll(['Foo', 'A']);
2234
expect(ReactNoop).toMatchRenderedOutput(<span prop="A" />);
2235
2259
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
2236
+ if (gate(flags => flags.forceConcurrentByDefaultForTesting)) {
2237
+ ReactNoop.render(<Foo showB={true} />);
2238
+ } else {
2239
React.startTransition(() => {
2240
ReactNoop.render(<Foo showB={true} />);
2241
});
2263
- } else {
2264
- ReactNoop.render(<Foo showB={true} />);
2242
}
2243
2244
await waitForAll(['Foo', 'A', 'Suspend! [B]', 'Loading B...']);
2245
2269
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
2270
- // Transitions never fall back.
2271
- expect(ReactNoop).toMatchRenderedOutput(<span prop="A" />);
2272
- } else {
2246
+ if (gate(flags => flags.forceConcurrentByDefaultForTesting)) {
2247
expect(ReactNoop).toMatchRenderedOutput(
2248
<>
2249
<span prop="A" />
2250
<span prop="Loading B..." />
2251
</>,
2252
);
2253
+ } else {
2254
+ // Transitions never fall back.
2255
+ expect(ReactNoop).toMatchRenderedOutput(<span prop="A" />);
2256
}
2257
});
2258
@@ -2301,13 +2278,9 @@ describe('ReactSuspenseWithNoopRenderer', () => {
2278
await waitForAll(['Foo', 'A']);
2279
expect(ReactNoop).toMatchRenderedOutput(<span prop="A" />);
2280
2304
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
2305
- React.startTransition(() => {
2306
- ReactNoop.render(<Foo showB={true} />);
2307
- });
2308
- } else {
2281
+ React.startTransition(() => {
2282
ReactNoop.render(<Foo showB={true} />);
2310
- }
2283
+ });
2284
2285
await waitForAll([
2286
'Foo',
@@ -2322,12 +2295,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
2295
Scheduler.unstable_advanceTime(600);
2296
await advanceTimers(600);
2297
2325
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
2326
- // Transitions never fall back.
2327
- expect(ReactNoop).toMatchRenderedOutput(<span prop="A" />);
2328
- } else {
2329
- expect(ReactNoop).toMatchRenderedOutput(<span prop="A" />);
2330
- }
2298
+ expect(ReactNoop).toMatchRenderedOutput(<span prop="A" />);
2299
});
2300
2301
describe('startTransition', () => {
@@ -3537,7 +3505,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
3505
});
3506
3507
// @gate enableLegacyCache
3540
- // @gate !enableSyncDefaultUpdates
3508
+ // @gate forceConcurrentByDefaultForTesting
3509
it('regression: ping at high priority causes update to be dropped', async () => {
3510
const {useState, useTransition} = React;
3511
packages/react-reconciler/src/__tests__/useMutableSource-test.internal.js
+36
-152
@@ -221,27 +221,7 @@ describe('useMutableSource', () => {
221
const mutableSource = createMutableSource(source, param => param.version);
222
223
await act(async () => {
224
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
225
- React.startTransition(() => {
226
- ReactNoop.render(
227
- <>
228
- <Component
229
- label="a"
230
- getSnapshot={defaultGetSnapshot}
231
- mutableSource={mutableSource}
232
- subscribe={defaultSubscribe}
233
- />
234
- <Component
235
- label="b"
236
- getSnapshot={defaultGetSnapshot}
237
- mutableSource={mutableSource}
238
- subscribe={defaultSubscribe}
239
- />
240
- </>,
241
- () => Scheduler.log('Sync effect'),
242
- );
243
- });
244
- } else {
224
+ React.startTransition(() => {
225
ReactNoop.render(
226
<>
227
<Component
@@ -259,7 +239,8 @@ describe('useMutableSource', () => {
239
</>,
240
() => Scheduler.log('Sync effect'),
241
);
262
- }
242
+ });
243
+
244
// Do enough work to read from one component
245
await waitFor(['a:one']);
246
@@ -456,13 +437,9 @@ describe('useMutableSource', () => {
437
438
// Changing values should schedule an update with React.
439
// Start working on this update but don't finish it.
459
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
460
- React.startTransition(() => {
461
- source.value = 'two';
462
- });
463
- } else {
440
+ React.startTransition(() => {
441
source.value = 'two';
465
- }
442
+ });
443
await waitFor(['a:two']);
444
445
// Re-renders that occur before the update is processed
@@ -720,33 +697,7 @@ describe('useMutableSource', () => {
697
698
// Because the store has not changed yet, there are no pending updates,
699
// so it is considered safe to read from when we start this render.
723
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
724
- React.startTransition(() => {
725
- ReactNoop.render(
726
- <>
727
- <Component
728
- label="a"
729
- getSnapshot={getSnapshotA}
730
- mutableSource={mutableSource}
731
- subscribe={subscribeA}
732
- />
733
- <Component
734
- label="b"
735
- getSnapshot={getSnapshotB}
736
- mutableSource={mutableSource}
737
- subscribe={subscribeB}
738
- />
739
- <Component
740
- label="c"
741
- getSnapshot={getSnapshotB}
742
- mutableSource={mutableSource}
743
- subscribe={subscribeB}
744
- />
745
- </>,
746
- () => Scheduler.log('Sync effect'),
747
- );
748
- });
749
- } else {
700
+ React.startTransition(() => {
701
ReactNoop.render(
702
<>
703
<Component
@@ -770,7 +721,8 @@ describe('useMutableSource', () => {
721
</>,
722
() => Scheduler.log('Sync effect'),
723
);
773
- }
724
+ });
725
+
726
await waitFor(['a:a:one', 'b:b:one']);
727
728
// Mutating the source should trigger a tear detection on the next read,
@@ -856,26 +808,7 @@ describe('useMutableSource', () => {
808
809
await act(async () => {
810
// Start a render that uses the mutable source.
859
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
860
- React.startTransition(() => {
861
- ReactNoop.render(
862
- <>
863
- <Component
864
- label="a"
865
- getSnapshot={defaultGetSnapshot}
866
- mutableSource={mutableSource}
867
- subscribe={defaultSubscribe}
868
- />
869
- <Component
870
- label="b"
871
- getSnapshot={defaultGetSnapshot}
872
- mutableSource={mutableSource}
873
- subscribe={defaultSubscribe}
874
- />
875
- </>,
876
- );
877
- });
878
- } else {
811
+ React.startTransition(() => {
812
ReactNoop.render(
813
<>
814
<Component
@@ -892,7 +825,8 @@ describe('useMutableSource', () => {
825
/>
826
</>,
827
);
895
- }
828
+ });
829
+
830
await waitFor(['a:one']);
831
832
// Mutate source
@@ -1524,17 +1458,7 @@ describe('useMutableSource', () => {
1458
expect(root).toMatchRenderedOutput('a0');
1459
1460
await act(async () => {
1527
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
1528
- React.startTransition(() => {
1529
- root.render(
1530
- <>
1531
- <Read getSnapshot={getSnapshotA} />
1532
- <Read getSnapshot={getSnapshotB} />
1533
- <Text text="c" />
1534
- </>,
1535
- );
1536
- });
1537
- } else {
1461
+ React.startTransition(() => {
1462
root.render(
1463
<>
1464
<Read getSnapshot={getSnapshotA} />
@@ -1542,7 +1466,7 @@ describe('useMutableSource', () => {
1466
<Text text="c" />
1467
</>,
1468
);
1545
- }
1469
+ });
1470
1471
await waitFor(['a0', 'b0']);
1472
// Mutate in an event. This schedules a subscription update on a, which
@@ -1676,13 +1600,9 @@ describe('useMutableSource', () => {
1600
1601
await act(async () => {
1602
// Switch the parent and the child to read using the same config
1679
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
1680
- React.startTransition(() => {
1681
- root.render(<App parentConfig={configB} childConfig={configB} />);
1682
- });
1683
- } else {
1603
+ React.startTransition(() => {
1604
root.render(<App parentConfig={configB} childConfig={configB} />);
1685
- }
1605
+ });
1606
// Start rendering the parent, but yield before rendering the child
1607
await waitFor(['Parent: 2']);
1608
@@ -1693,21 +1613,7 @@ describe('useMutableSource', () => {
1613
source.valueB = '3';
1614
});
1615
1696
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
1697
- // In default sync mode, all of the updates flush sync.
1698
- await waitFor([
1699
- // The partial render completes
1700
- 'Child: 2',
1701
- 'Commit: 2, 2',
1702
- 'Parent: 3',
1703
- 'Child: 3',
1704
- ]);
1705
-
1706
- await waitForAll([
1707
- // Now finish the rest of the update
1708
- 'Commit: 3, 3',
1709
- ]);
1710
- } else {
1616
+ if (gate(flags => flags.forceConcurrentByDefaultForTesting)) {
1617
await waitFor([
1618
// The partial render completes
1619
'Child: 2',
@@ -1727,6 +1633,20 @@ describe('useMutableSource', () => {
1633
'Child: 3',
1634
'Commit: 3, 3',
1635
]);
1636
+ } else {
1637
+ // In default sync mode, all of the updates flush sync.
1638
+ await waitFor([
1639
+ // The partial render completes
1640
+ 'Child: 2',
1641
+ 'Commit: 2, 2',
1642
+ 'Parent: 3',
1643
+ 'Child: 3',
1644
+ ]);
1645
+
1646
+ await waitForAll([
1647
+ // Now finish the rest of the update
1648
+ 'Commit: 3, 3',
1649
+ ]);
1650
}
1651
});
1652
});
@@ -1843,26 +1763,7 @@ describe('useMutableSource', () => {
1763
1764
await act(async () => {
1765
// Start a render that uses the mutable source.
1846
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
1847
- React.startTransition(() => {
1848
- ReactNoop.render(
1849
- <>
1850
- <Component
1851
- label="a"
1852
- getSnapshot={defaultGetSnapshot}
1853
- mutableSource={mutableSource}
1854
- subscribe={defaultSubscribe}
1855
- />
1856
- <Component
1857
- label="b"
1858
- getSnapshot={defaultGetSnapshot}
1859
- mutableSource={mutableSource}
1860
- subscribe={defaultSubscribe}
1861
- />
1862
- </>,
1863
- );
1864
- });
1865
- } else {
1766
+ React.startTransition(() => {
1767
ReactNoop.render(
1768
<>
1769
<Component
@@ -1879,7 +1780,8 @@ describe('useMutableSource', () => {
1780
/>
1781
</>,
1782
);
1882
- }
1783
+ });
1784
+
1785
await waitFor(['a:one']);
1786
1787
const PrevScheduler = Scheduler;
@@ -1924,26 +1826,7 @@ describe('useMutableSource', () => {
1826
1827
await act(async () => {
1828
// Start a render that uses the mutable source.
1927
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
1928
- React.startTransition(() => {
1929
- ReactNoop.render(
1930
- <>
1931
- <Component
1932
- label="a"
1933
- getSnapshot={defaultGetSnapshot}
1934
- mutableSource={mutableSource}
1935
- subscribe={defaultSubscribe}
1936
- />
1937
- <Component
1938
- label="b"
1939
- getSnapshot={defaultGetSnapshot}
1940
- mutableSource={mutableSource}
1941
- subscribe={defaultSubscribe}
1942
- />
1943
- </>,
1944
- );
1945
- });
1946
- } else {
1829
+ React.startTransition(() => {
1830
ReactNoop.render(
1831
<>
1832
<Component
@@ -1960,7 +1843,8 @@ describe('useMutableSource', () => {
1843
/>
1844
</>,
1845
);
1963
- }
1846
+ });
1847
+
1848
await waitFor(['a:one']);
1849
1850
const PrevScheduler = Scheduler;
packages/react-reconciler/src/__tests__/useMutableSourceHydration-test.js
+3
-11
@@ -260,23 +260,15 @@ describe('useMutableSourceHydration', () => {
260
261
await expect(async () => {
262
await act(async () => {
263
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
264
- React.startTransition(() => {
265
- ReactDOMClient.hydrateRoot(container, <TestComponent />, {
266
- mutableSources: [mutableSource],
267
- onRecoverableError(error) {
268
- Scheduler.log('Log error: ' + error.message);
269
- },
270
- });
271
- });
272
- } else {
263
+ React.startTransition(() => {
264
ReactDOMClient.hydrateRoot(container, <TestComponent />, {
265
mutableSources: [mutableSource],
266
onRecoverableError(error) {
267
Scheduler.log('Log error: ' + error.message);
268
},
269
});
279
- }
270
+ });
271
+
272
await waitFor(['a:one']);
273
source.value = 'two';
274
});
packages/react-test-renderer/src/__tests__/ReactTestRendererAsync-test.js
+4
-16
@@ -95,17 +95,11 @@ describe('ReactTestRendererAsync', () => {
95
}
96
97
let renderer;
98
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
99
- React.startTransition(() => {
100
- renderer = ReactTestRenderer.create(<Parent step={1} />, {
101
- unstable_isConcurrent: true,
102
- });
103
- });
104
- } else {
98
+ React.startTransition(() => {
99
renderer = ReactTestRenderer.create(<Parent step={1} />, {
100
unstable_isConcurrent: true,
101
});
108
- }
102
+ });
103
104
// Flush the first two siblings
105
await waitFor(['A:1', 'B:1']);
@@ -141,17 +135,11 @@ describe('ReactTestRendererAsync', () => {
135
}
136
137
let renderer;
144
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
145
- React.startTransition(() => {
146
- renderer = ReactTestRenderer.create(<Example step={1} />, {
147
- unstable_isConcurrent: true,
148
- });
149
- });
150
- } else {
138
+ React.startTransition(() => {
139
renderer = ReactTestRenderer.create(<Example step={1} />, {
140
unstable_isConcurrent: true,
141
});
154
- }
142
+ });
143
144
// Flush the some of the changes, but don't commit
145
await waitFor(['A:1']);
packages/react/src/__tests__/ReactProfiler-test.internal.js
+17
-71
@@ -206,19 +206,7 @@ describe(`onRender`, () => {
206
return null;
207
};
208
209
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
210
- React.startTransition(() => {
211
- ReactTestRenderer.create(
212
- <React.Profiler id="test" onRender={callback}>
213
- <Yield value="first" />
214
- <Yield value="last" />
215
- </React.Profiler>,
216
- {
217
- unstable_isConcurrent: true,
218
- },
219
- );
220
- });
221
- } else {
209
+ React.startTransition(() => {
210
ReactTestRenderer.create(
211
<React.Profiler id="test" onRender={callback}>
212
<Yield value="first" />
@@ -228,7 +216,7 @@ describe(`onRender`, () => {
216
unstable_isConcurrent: true,
217
},
218
);
231
- }
219
+ });
220
221
// Times are logged until a render is committed.
222
await waitFor(['first']);
@@ -758,17 +746,7 @@ describe(`onRender`, () => {
746
Scheduler.unstable_advanceTime(5); // 0 -> 5
747
748
// Render partially, but run out of time before completing.
761
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
762
- React.startTransition(() => {
763
- ReactTestRenderer.create(
764
- <React.Profiler id="test" onRender={callback}>
765
- <Yield renderTime={2} />
766
- <Yield renderTime={3} />
767
- </React.Profiler>,
768
- {unstable_isConcurrent: true},
769
- );
770
- });
771
- } else {
749
+ React.startTransition(() => {
750
ReactTestRenderer.create(
751
<React.Profiler id="test" onRender={callback}>
752
<Yield renderTime={2} />
@@ -776,7 +754,8 @@ describe(`onRender`, () => {
754
</React.Profiler>,
755
{unstable_isConcurrent: true},
756
);
779
- }
757
+ });
758
+
759
await waitFor(['Yield:2']);
760
expect(callback).toHaveBeenCalledTimes(0);
761
@@ -805,20 +784,7 @@ describe(`onRender`, () => {
784
785
// Render partially, but don't finish.
786
// This partial render should take 5ms of simulated time.
808
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
809
- React.startTransition(() => {
810
- ReactTestRenderer.create(
811
- <React.Profiler id="outer" onRender={callback}>
812
- <Yield renderTime={5} />
813
- <Yield renderTime={10} />
814
- <React.Profiler id="inner" onRender={callback}>
815
- <Yield renderTime={17} />
816
- </React.Profiler>
817
- </React.Profiler>,
818
- {unstable_isConcurrent: true},
819
- );
820
- });
821
- } else {
787
+ React.startTransition(() => {
788
ReactTestRenderer.create(
789
<React.Profiler id="outer" onRender={callback}>
790
<Yield renderTime={5} />
@@ -829,7 +795,8 @@ describe(`onRender`, () => {
795
</React.Profiler>,
796
{unstable_isConcurrent: true},
797
);
832
- }
798
+ });
799
+
800
await waitFor(['Yield:5']);
801
expect(callback).toHaveBeenCalledTimes(0);
802
@@ -871,17 +838,7 @@ describe(`onRender`, () => {
838
// Render a partially update, but don't finish.
839
// This partial render should take 10ms of simulated time.
840
let renderer;
874
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
875
- React.startTransition(() => {
876
- renderer = ReactTestRenderer.create(
877
- <React.Profiler id="test" onRender={callback}>
878
- <Yield renderTime={10} />
879
- <Yield renderTime={20} />
880
- </React.Profiler>,
881
- {unstable_isConcurrent: true},
882
- );
883
- });
884
- } else {
841
+ React.startTransition(() => {
842
renderer = ReactTestRenderer.create(
843
<React.Profiler id="test" onRender={callback}>
844
<Yield renderTime={10} />
@@ -889,7 +846,8 @@ describe(`onRender`, () => {
846
</React.Profiler>,
847
{unstable_isConcurrent: true},
848
);
892
- }
849
+ });
850
+
851
await waitFor(['Yield:10']);
852
expect(callback).toHaveBeenCalledTimes(0);
853
@@ -958,17 +916,7 @@ describe(`onRender`, () => {
916
917
// Render a partially update, but don't finish.
918
// This partial render should take 3ms of simulated time.
961
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
962
- React.startTransition(() => {
963
- renderer.update(
964
- <React.Profiler id="test" onRender={callback}>
965
- <Yield renderTime={3} />
966
- <Yield renderTime={5} />
967
- <Yield renderTime={9} />
968
- </React.Profiler>,
969
- );
970
- });
971
- } else {
919
+ React.startTransition(() => {
920
renderer.update(
921
<React.Profiler id="test" onRender={callback}>
922
<Yield renderTime={3} />
@@ -976,7 +924,8 @@ describe(`onRender`, () => {
924
<Yield renderTime={9} />
925
</React.Profiler>,
926
);
979
- }
927
+ });
928
+
929
await waitFor(['Yield:3']);
930
expect(callback).toHaveBeenCalledTimes(0);
931
@@ -1078,13 +1027,10 @@ describe(`onRender`, () => {
1027
1028
// Render a partially update, but don't finish.
1029
// This partial render will take 10ms of actual render time.
1081
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
1082
- React.startTransition(() => {
1083
- first.setState({renderTime: 10});
1084
- });
1085
- } else {
1030
+ React.startTransition(() => {
1031
first.setState({renderTime: 10});
1087
- }
1032
+ });
1033
+
1034
await waitFor(['FirstComponent:10']);
1035
expect(callback).toHaveBeenCalledTimes(0);
1036
packages/react/src/__tests__/ReactProfilerDevToolsIntegration-test.internal.js
+2
-6
@@ -161,13 +161,9 @@ describe('ReactProfiler DevTools integration', () => {
161
// for updates.
162
Scheduler.unstable_advanceTime(10000);
163
// Schedule an update.
164
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
165
- React.startTransition(() => {
166
- root.update(<Text text="B" />);
167
- });
168
- } else {
164
+ React.startTransition(() => {
165
root.update(<Text text="B" />);
170
- }
166
+ });
167
168
// Update B should not instantly expire.
169
await waitFor([]);
packages/shared/ReactFeatureFlags.js
+2
-3
@@ -145,12 +145,11 @@ export const disableLegacyContext = false;
145
export const enableUseRefAccessWarning = false;
146
147
// Enables time slicing for updates that aren't wrapped in startTransition.
148
-export const enableSyncDefaultUpdates = true;
148
+export const forceConcurrentByDefaultForTesting = false;
149
150
export const enableUnifiedSyncLane = __EXPERIMENTAL__;
151
152
-// Adds an opt-in to time slicing for updates that aren't wrapped in
153
-// startTransition. Only relevant when enableSyncDefaultUpdates is disabled.
152
+// Adds an opt-in to time slicing for updates that aren't wrapped in startTransition.
153
export const allowConcurrentByDefault = false;
154
155
// -----------------------------------------------------------------------------
packages/shared/forks/ReactFeatureFlags.native-fb.js
+1
-1
@@ -66,7 +66,7 @@ export const createRootStrictEffectsByDefault = false;
66
export const disableSchedulerTimeoutInWorkLoop = false;
67
export const enableLazyContextPropagation = false;
68
export const enableLegacyHidden = true;
69
-export const enableSyncDefaultUpdates = true;
69
+export const forceConcurrentByDefaultForTesting = false;
70
export const enableUnifiedSyncLane = false;
71
export const allowConcurrentByDefault = true;
72
export const enableCustomElementPropertySupport = false;
packages/shared/forks/ReactFeatureFlags.native-oss.js
+1
-1
@@ -53,7 +53,7 @@ export const enableUseRefAccessWarning = false;
53
export const disableSchedulerTimeoutInWorkLoop = false;
54
export const enableLazyContextPropagation = false;
55
export const enableLegacyHidden = false;
56
-export const enableSyncDefaultUpdates = true;
56
+export const forceConcurrentByDefaultForTesting = false;
57
export const enableUnifiedSyncLane = false;
58
export const allowConcurrentByDefault = false;
59
export const enableCustomElementPropertySupport = false;
packages/shared/forks/ReactFeatureFlags.test-renderer.js
+1
-1
@@ -53,7 +53,7 @@ export const enableUseRefAccessWarning = false;
53
export const disableSchedulerTimeoutInWorkLoop = false;
54
export const enableLazyContextPropagation = false;
55
export const enableLegacyHidden = false;
56
-export const enableSyncDefaultUpdates = true;
56
+export const forceConcurrentByDefaultForTesting = false;
57
export const enableUnifiedSyncLane = __EXPERIMENTAL__;
58
export const allowConcurrentByDefault = false;
59
export const enableCustomElementPropertySupport = false;
packages/shared/forks/ReactFeatureFlags.test-renderer.native.js
+1
-1
@@ -52,7 +52,7 @@ export const enableUseRefAccessWarning = false;
52
export const disableSchedulerTimeoutInWorkLoop = false;
53
export const enableLazyContextPropagation = false;
54
export const enableLegacyHidden = false;
55
-export const enableSyncDefaultUpdates = true;
55
+export const forceConcurrentByDefaultForTesting = false;
56
export const enableUnifiedSyncLane = false;
57
export const allowConcurrentByDefault = true;
58
packages/shared/forks/ReactFeatureFlags.test-renderer.www.js
+1
-1
@@ -53,7 +53,7 @@ export const enableUseRefAccessWarning = false;
53
export const disableSchedulerTimeoutInWorkLoop = false;
54
export const enableLazyContextPropagation = false;
55
export const enableLegacyHidden = false;
56
-export const enableSyncDefaultUpdates = true;
56
+export const forceConcurrentByDefaultForTesting = false;
57
export const enableUnifiedSyncLane = false;
58
export const allowConcurrentByDefault = true;
59
export const enableCustomElementPropertySupport = false;
packages/shared/forks/ReactFeatureFlags.www-dynamic.js
+1
-1
@@ -20,7 +20,7 @@ export const enableUseRefAccessWarning = __VARIANT__;
20
export const enableProfilerNestedUpdateScheduledHook = __VARIANT__;
21
export const disableSchedulerTimeoutInWorkLoop = __VARIANT__;
22
export const enableLazyContextPropagation = __VARIANT__;
23
-export const enableSyncDefaultUpdates = __VARIANT__;
23
+export const forceConcurrentByDefaultForTesting = __VARIANT__;
24
export const enableUnifiedSyncLane = __VARIANT__;
25
export const enableTransitionTracing = __VARIANT__;
26
export const enableCustomElementPropertySupport = __VARIANT__;
packages/shared/forks/ReactFeatureFlags.www.js
+1
-1
@@ -105,7 +105,7 @@ export const enableUseMutableSource = true;
105
export const useModernStrictMode = false;
106
export const enableFizzExternalRuntime = true;
107
108
-export const enableSyncDefaultUpdates = true;
108
+export const forceConcurrentByDefaultForTesting = false;
109
110
// Flow magic to verify the exports of this file match the original version.
111
((((null: any): ExportsType): FeatureFlagsType): ExportsType);
packages/use-subscription/src/__tests__/useSubscription-test.js
+8
-24
@@ -339,13 +339,9 @@ describe('useSubscription', () => {
339
340
// Start React update, but don't finish
341
await act(async () => {
342
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
343
- React.startTransition(() => {
344
- renderer.update(<Parent observed={observableB} />);
345
- });
346
- } else {
342
+ React.startTransition(() => {
343
renderer.update(<Parent observed={observableB} />);
348
- }
344
+ });
345
346
await waitFor(['Child: b-0']);
347
expect(log).toEqual(['Parent.componentDidMount']);
@@ -447,13 +443,9 @@ describe('useSubscription', () => {
443
444
// Start React update, but don't finish
445
await act(async () => {
450
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
451
- React.startTransition(() => {
452
- renderer.update(<Parent observed={observableB} />);
453
- });
454
- } else {
446
+ React.startTransition(() => {
447
renderer.update(<Parent observed={observableB} />);
456
- }
448
+ });
449
await waitFor(['Child: b-0']);
450
expect(log).toEqual([]);
451
@@ -632,21 +624,13 @@ describe('useSubscription', () => {
624
// Interrupt with a second mutation "C" -> "D".
625
// This update will not be eagerly evaluated,
626
// but useSubscription() should eagerly close over the updated value to avoid tearing.
635
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
636
- React.startTransition(() => {
637
- mutate('C');
638
- });
639
- } else {
627
+ React.startTransition(() => {
628
mutate('C');
641
- }
629
+ });
630
await waitFor(['render:first:C', 'render:second:C']);
643
- if (gate(flags => flags.enableSyncDefaultUpdates)) {
644
- React.startTransition(() => {
645
- mutate('D');
646
- });
647
- } else {
631
+ React.startTransition(() => {
632
mutate('D');
649
- }
633
+ });
634
await waitForAll(['render:first:D', 'render:second:D']);
635
636
// No more pending updates
scripts/jest/setupTests.www.js
+1
-1
@@ -9,7 +9,7 @@ jest.mock('shared/ReactFeatureFlags', () => {
9
const actual = jest.requireActual('shared/forks/ReactFeatureFlags.www');
10
11
// This flag is only used by tests, it should never be set elsewhere.
12
- actual.enableSyncDefaultUpdates = __VARIANT__;
12
+ actual.forceConcurrentByDefaultForTesting = !__VARIANT__;
13
14
return actual;
15
});