Skip to content

Commit b2ae9dd

Browse files
authored
Cleanup enableSyncDefaultUpdate flag (#26236)
This feature flag is enabled everywhere.
1 parent 6ff1733 commit b2ae9dd

File tree

38 files changed

+271
-1382
lines changed

38 files changed

+271
-1382
lines changed

packages/react-art/src/__tests__/ReactART-test.js

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ const ReactTestRenderer = require('react-test-renderer');
3333

3434
// Isolate the noop renderer
3535
jest.resetModules();
36-
const ReactNoop = require('react-noop-renderer');
37-
const Scheduler = require('scheduler');
3836

3937
let Group;
4038
let Shape;
@@ -359,58 +357,6 @@ describe('ReactART', () => {
359357
doClick(instance);
360358
expect(onClick2).toBeCalled();
361359
});
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-
});
414360
});
415361

416362
describe('ReactARTComponents', () => {

packages/react-dom/src/__tests__/ReactDOMNativeEventHeuristic-test.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -305,11 +305,7 @@ describe('ReactDOMNativeEventHeuristic-test', () => {
305305
expect(container.textContent).toEqual('not hovered');
306306

307307
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');
313309
});
314310
expect(container.textContent).toEqual('hovered');
315311
});

packages/react-dom/src/__tests__/ReactDOMServerPartialHydration-test.internal.js

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2044,14 +2044,7 @@ describe('ReactDOMServerPartialHydration', () => {
20442044
suspend = true;
20452045

20462046
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']);
20552048

20562049
// This will cause us to skip the second row completely.
20572050
});

packages/react-dom/src/events/__tests__/DOMPluginEventSystem-test.internal.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1965,13 +1965,9 @@ describe('DOMPluginEventSystem', () => {
19651965
log.length = 0;
19661966

19671967
// Increase counter
1968-
if (gate(flags => flags.enableSyncDefaultUpdates)) {
1969-
React.startTransition(() => {
1970-
root.render(<Test counter={1} />);
1971-
});
1972-
} else {
1968+
React.startTransition(() => {
19731969
root.render(<Test counter={1} />);
1974-
}
1970+
});
19751971
// Yield before committing
19761972
expect(Scheduler).toFlushAndYieldThrough(['Test']);
19771973

packages/react-reconciler/src/ReactFiber.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ import {
3333
enableProfilerTimer,
3434
enableScopeAPI,
3535
enableLegacyHidden,
36-
enableSyncDefaultUpdates,
3736
allowConcurrentByDefault,
3837
enableTransitionTracing,
3938
enableDebugTracing,
@@ -459,11 +458,9 @@ export function createHostRootFiber(
459458
mode |= StrictLegacyMode | StrictEffectsMode;
460459
}
461460
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 ||
465461
// Only for internal experiments.
466-
(allowConcurrentByDefault && concurrentUpdatesByDefaultOverride)
462+
allowConcurrentByDefault &&
463+
concurrentUpdatesByDefaultOverride
467464
) {
468465
mode |= ConcurrentUpdatesByDefaultMode;
469466
}

packages/react-reconciler/src/__tests__/ReactDisableSchedulerTimeoutBasedOnReactExpirationTime-test.internal.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,9 @@ describe('ReactSuspenseList', () => {
6363
root.render(<App show={false} />);
6464
expect(Scheduler).toFlushAndYield([]);
6565

66-
if (gate(flags => flags.enableSyncDefaultUpdates)) {
67-
React.startTransition(() => {
68-
root.render(<App show={true} />);
69-
});
70-
} else {
66+
React.startTransition(() => {
7167
root.render(<App show={true} />);
72-
}
68+
});
7369
expect(Scheduler).toFlushAndYield([
7470
'Suspend! [A]',
7571
'Suspend! [B]',

packages/react-reconciler/src/__tests__/ReactExpiration-test.js

Lines changed: 24 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -115,13 +115,9 @@ describe('ReactExpiration', () => {
115115
}
116116

117117
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(() => {
123119
ReactNoop.render(<span prop="done" />);
124-
}
120+
});
125121

126122
expect(ReactNoop).toMatchRenderedOutput(null);
127123

@@ -162,13 +158,9 @@ describe('ReactExpiration', () => {
162158

163159
// First, show what happens for updates in two separate events.
164160
// Schedule an update.
165-
if (gate(flags => flags.enableSyncDefaultUpdates)) {
166-
React.startTransition(() => {
167-
ReactNoop.render(<TextClass text="A" />);
168-
});
169-
} else {
161+
React.startTransition(() => {
170162
ReactNoop.render(<TextClass text="A" />);
171-
}
163+
});
172164
// Advance the timer.
173165
Scheduler.unstable_advanceTime(2000);
174166
// Partially flush the first update, then interrupt it.
@@ -223,13 +215,9 @@ describe('ReactExpiration', () => {
223215

224216
// First, show what happens for updates in two separate events.
225217
// Schedule an update.
226-
if (gate(flags => flags.enableSyncDefaultUpdates)) {
227-
React.startTransition(() => {
228-
ReactNoop.render(<TextClass text="A" />);
229-
});
230-
} else {
218+
React.startTransition(() => {
231219
ReactNoop.render(<TextClass text="A" />);
232-
}
220+
});
233221
// Advance the timer.
234222
Scheduler.unstable_advanceTime(2000);
235223
// Partially flush the first update, then interrupt it.
@@ -301,13 +289,9 @@ describe('ReactExpiration', () => {
301289
}
302290

303291
// Initial mount
304-
if (gate(flags => flags.enableSyncDefaultUpdates)) {
305-
React.startTransition(() => {
306-
ReactNoop.render(<App />);
307-
});
308-
} else {
292+
React.startTransition(() => {
309293
ReactNoop.render(<App />);
310-
}
294+
});
311295
expect(Scheduler).toFlushAndYield([
312296
'initial [A] [render]',
313297
'initial [B] [render]',
@@ -320,13 +304,9 @@ describe('ReactExpiration', () => {
320304
]);
321305

322306
// 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(() => {
328308
subscribers.forEach(s => s.setState({text: '1'}));
329-
}
309+
});
330310
expect(Scheduler).toFlushAndYieldThrough([
331311
'1 [A] [render]',
332312
'1 [B] [render]',
@@ -358,13 +338,9 @@ describe('ReactExpiration', () => {
358338
);
359339
}
360340

361-
if (gate(flags => flags.enableSyncDefaultUpdates)) {
362-
React.startTransition(() => {
363-
root.render(<App />);
364-
});
365-
} else {
341+
React.startTransition(() => {
366342
root.render(<App />);
367-
}
343+
});
368344

369345
expect(Scheduler).toFlushAndYieldThrough(['A']);
370346
expect(Scheduler).toFlushAndYieldThrough(['B']);
@@ -392,13 +368,9 @@ describe('ReactExpiration', () => {
392368
</>
393369
);
394370
}
395-
if (gate(flags => flags.enableSyncDefaultUpdates)) {
396-
React.startTransition(() => {
397-
root.render(<App />);
398-
});
399-
} else {
371+
React.startTransition(() => {
400372
root.render(<App />);
401-
}
373+
});
402374

403375
expect(Scheduler).toFlushAndYieldThrough(['A']);
404376
expect(Scheduler).toFlushAndYieldThrough(['B']);
@@ -426,13 +398,9 @@ describe('ReactExpiration', () => {
426398
// current time.
427399
ReactNoop = require('react-noop-renderer');
428400

429-
if (gate(flags => flags.enableSyncDefaultUpdates)) {
430-
React.startTransition(() => {
431-
ReactNoop.render('Hi');
432-
});
433-
} else {
401+
React.startTransition(() => {
434402
ReactNoop.render('Hi');
435-
}
403+
});
436404

437405
// The update should not have expired yet.
438406
flushNextRenderIfExpired();
@@ -455,13 +423,9 @@ describe('ReactExpiration', () => {
455423
// Before scheduling an update, advance the current time.
456424
Scheduler.unstable_advanceTime(10000);
457425

458-
if (gate(flags => flags.enableSyncDefaultUpdates)) {
459-
React.startTransition(() => {
460-
ReactNoop.render('Hi');
461-
});
462-
} else {
426+
React.startTransition(() => {
463427
ReactNoop.render('Hi');
464-
}
428+
});
465429
flushNextRenderIfExpired();
466430
expect(Scheduler).toHaveYielded([]);
467431
expect(ReactNoop).toMatchRenderedOutput(null);
@@ -504,13 +468,9 @@ describe('ReactExpiration', () => {
504468

505469
// First demonstrate what happens when there's no starvation
506470
await act(async () => {
507-
if (gate(flags => flags.enableSyncDefaultUpdates)) {
508-
React.startTransition(() => {
509-
updateNormalPri();
510-
});
511-
} else {
471+
React.startTransition(() => {
512472
updateNormalPri();
513-
}
473+
});
514474
expect(Scheduler).toFlushAndYieldThrough(['Sync pri: 0']);
515475
updateSyncPri();
516476
expect(Scheduler).toHaveYielded(['Sync pri: 1', 'Normal pri: 0']);
@@ -528,13 +488,9 @@ describe('ReactExpiration', () => {
528488

529489
// Do the same thing, but starve the first update
530490
await act(async () => {
531-
if (gate(flags => flags.enableSyncDefaultUpdates)) {
532-
React.startTransition(() => {
533-
updateNormalPri();
534-
});
535-
} else {
491+
React.startTransition(() => {
536492
updateNormalPri();
537-
}
493+
});
538494
expect(Scheduler).toFlushAndYieldThrough(['Sync pri: 1']);
539495

540496
// This time, a lot of time has elapsed since the normal pri update
@@ -690,13 +646,9 @@ describe('ReactExpiration', () => {
690646
expect(root).toMatchRenderedOutput('A0BC');
691647

692648
await act(async () => {
693-
if (gate(flags => flags.enableSyncDefaultUpdates)) {
694-
React.startTransition(() => {
695-
root.render(<App step={1} />);
696-
});
697-
} else {
649+
React.startTransition(() => {
698650
root.render(<App step={1} />);
699-
}
651+
});
700652
expect(Scheduler).toFlushAndYield([
701653
'Suspend! [A1]',
702654
'B',

packages/react-reconciler/src/__tests__/ReactFlushSync-test.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,9 @@ describe('ReactFlushSync', () => {
4141

4242
const root = ReactNoop.createRoot();
4343
await act(async () => {
44-
if (gate(flags => flags.enableSyncDefaultUpdates)) {
45-
React.startTransition(() => {
46-
root.render(<App />);
47-
});
48-
} else {
44+
React.startTransition(() => {
4945
root.render(<App />);
50-
}
46+
});
5147
// This will yield right before the passive effect fires
5248
expect(Scheduler).toFlushUntilNextPaint(['0, 0']);
5349

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy