Skip to content

Commit c21bcd6

Browse files
authored
Clean up enableUnifiedSyncLane flag (#30062)
`enableUnifiedSyncLane` now passes everywhere. Let's clean it up Implemented with #27646 Flag enabled with #27646, #28269, #29052
1 parent 7608516 commit c21bcd6

20 files changed

+62
-276
lines changed

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

+3-12
Original file line numberDiff line numberDiff line change
@@ -313,21 +313,12 @@ describe('ReactDOMFiberAsync', () => {
313313
assertLog([]);
314314
});
315315
// Only the active updates have flushed
316-
if (gate(flags => flags.enableUnifiedSyncLane)) {
317-
expect(container.textContent).toEqual('ABC');
318-
assertLog(['ABC']);
319-
} else {
320-
expect(container.textContent).toEqual('BC');
321-
assertLog(['BC']);
322-
}
316+
expect(container.textContent).toEqual('ABC');
317+
assertLog(['ABC']);
323318

324319
await act(() => {
325320
instance.push('D');
326-
if (gate(flags => flags.enableUnifiedSyncLane)) {
327-
expect(container.textContent).toEqual('ABC');
328-
} else {
329-
expect(container.textContent).toEqual('BC');
330-
}
321+
expect(container.textContent).toEqual('ABC');
331322
assertLog([]);
332323
});
333324
assertLog(['ABCD']);

packages/react-reconciler/src/ReactFiberLane.js

+6-10
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import {
2323
enableRetryLaneExpiration,
2424
enableSchedulingProfiler,
2525
enableTransitionTracing,
26-
enableUnifiedSyncLane,
2726
enableUpdaterTracking,
2827
syncLaneExpirationMs,
2928
transitionLaneExpirationMs,
@@ -51,9 +50,8 @@ export const InputContinuousLane: Lane = /* */ 0b0000000000000000000
5150
export const DefaultHydrationLane: Lane = /* */ 0b0000000000000000000000000010000;
5251
export const DefaultLane: Lane = /* */ 0b0000000000000000000000000100000;
5352

54-
export const SyncUpdateLanes: Lane = enableUnifiedSyncLane
55-
? SyncLane | InputContinuousLane | DefaultLane
56-
: SyncLane;
53+
export const SyncUpdateLanes: Lane =
54+
SyncLane | InputContinuousLane | DefaultLane;
5755

5856
const TransitionHydrationLane: Lane = /* */ 0b0000000000000000000000001000000;
5957
const TransitionLanes: Lanes = /* */ 0b0000000001111111111111110000000;
@@ -151,11 +149,9 @@ let nextTransitionLane: Lane = TransitionLane1;
151149
let nextRetryLane: Lane = RetryLane1;
152150

153151
function getHighestPriorityLanes(lanes: Lanes | Lane): Lanes {
154-
if (enableUnifiedSyncLane) {
155-
const pendingSyncLanes = lanes & SyncUpdateLanes;
156-
if (pendingSyncLanes !== 0) {
157-
return pendingSyncLanes;
158-
}
152+
const pendingSyncLanes = lanes & SyncUpdateLanes;
153+
if (pendingSyncLanes !== 0) {
154+
return pendingSyncLanes;
159155
}
160156
switch (getHighestPriorityLane(lanes)) {
161157
case SyncHydrationLane:
@@ -826,7 +822,7 @@ export function getBumpedLaneForHydration(
826822
const renderLane = getHighestPriorityLane(renderLanes);
827823

828824
let lane;
829-
if (enableUnifiedSyncLane && (renderLane & SyncUpdateLanes) !== NoLane) {
825+
if ((renderLane & SyncUpdateLanes) !== NoLane) {
830826
lane = SyncHydrationLane;
831827
} else {
832828
switch (renderLane) {

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

+2-7
Original file line numberDiff line numberDiff line change
@@ -698,15 +698,10 @@ describe('Activity', () => {
698698
);
699699

700700
// Before the inner update can finish, we receive another pair of updates.
701-
if (gate(flags => flags.enableUnifiedSyncLane)) {
702-
React.startTransition(() => {
703-
setOuter(2);
704-
setInner(2);
705-
});
706-
} else {
701+
React.startTransition(() => {
707702
setOuter(2);
708703
setInner(2);
709-
}
704+
});
710705

711706
// Also, before either of these new updates are processed, the hidden
712707
// tree is revealed at high priority.

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

+2-12
Original file line numberDiff line numberDiff line change
@@ -159,17 +159,7 @@ describe('ReactBlockingMode', () => {
159159
);
160160

161161
// Now flush the first update
162-
if (gate(flags => flags.enableUnifiedSyncLane)) {
163-
assertLog(['A1', 'B1']);
164-
expect(root).toMatchRenderedOutput('A1B1');
165-
} else {
166-
// Only the second update should have flushed synchronously
167-
assertLog(['B1']);
168-
expect(root).toMatchRenderedOutput('A0B1');
169-
170-
// Now flush the first update
171-
await waitForAll(['A1']);
172-
expect(root).toMatchRenderedOutput('A1B1');
173-
}
162+
assertLog(['A1', 'B1']);
163+
expect(root).toMatchRenderedOutput('A1B1');
174164
});
175165
});

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

+2-6
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,9 @@ describe('ReactClassSetStateCallback', () => {
3939
assertLog([0]);
4040

4141
await act(() => {
42-
if (gate(flags => flags.enableUnifiedSyncLane)) {
43-
React.startTransition(() => {
44-
app.setState({step: 1}, () => Scheduler.log('Callback 1'));
45-
});
46-
} else {
42+
React.startTransition(() => {
4743
app.setState({step: 1}, () => Scheduler.log('Callback 1'));
48-
}
44+
});
4945
ReactNoop.flushSync(() => {
5046
app.setState({step: 2}, () => Scheduler.log('Callback 2'));
5147
});

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

+2-9
Original file line numberDiff line numberDiff line change
@@ -102,20 +102,13 @@ describe('ReactFlushSync', () => {
102102

103103
// The passive effect will schedule a sync update and a normal update.
104104
// They should commit in two separate batches. First the sync one.
105-
await waitForPaint(
106-
gate(flags => flags.enableUnifiedSyncLane) ? ['1, 1'] : ['1, 0'],
107-
);
105+
await waitForPaint(['1, 1']);
108106

109107
// The remaining update is not sync
110108
ReactDOM.flushSync();
111109
assertLog([]);
112110

113-
if (gate(flags => flags.enableUnifiedSyncLane)) {
114-
await waitForPaint([]);
115-
} else {
116-
// Now flush it.
117-
await waitForPaint(['1, 1']);
118-
}
111+
await waitForPaint([]);
119112
});
120113
expect(getVisibleChildren(container)).toEqual('1, 1');
121114

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

+2-7
Original file line numberDiff line numberDiff line change
@@ -541,13 +541,8 @@ describe('ReactHooks', () => {
541541
});
542542
};
543543

544-
if (gate(flags => flags.enableUnifiedSyncLane)) {
545-
// Update at transition priority
546-
React.startTransition(() => update(n => n * 100));
547-
} else {
548-
// Update at normal priority
549-
ReactTestRenderer.unstable_batchedUpdates(() => update(n => n * 100));
550-
}
544+
// Update at transition priority
545+
React.startTransition(() => update(n => n * 100));
551546
// The new state is eagerly computed.
552547
assertLog(['Compute state (1 -> 100)']);
553548

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

+3-14
Original file line numberDiff line numberDiff line change
@@ -899,15 +899,8 @@ describe('ReactHooksWithNoopRenderer', () => {
899899
ReactNoop.flushSync(() => {
900900
counter.current.dispatch(INCREMENT);
901901
});
902-
if (gate(flags => flags.enableUnifiedSyncLane)) {
903-
assertLog(['Count: 4']);
904-
expect(ReactNoop).toMatchRenderedOutput(<span prop="Count: 4" />);
905-
} else {
906-
assertLog(['Count: 1']);
907-
expect(ReactNoop).toMatchRenderedOutput(<span prop="Count: 1" />);
908-
await waitForAll(['Count: 4']);
909-
expect(ReactNoop).toMatchRenderedOutput(<span prop="Count: 4" />);
910-
}
902+
assertLog(['Count: 4']);
903+
expect(ReactNoop).toMatchRenderedOutput(<span prop="Count: 4" />);
911904
});
912905
});
913906

@@ -1613,11 +1606,7 @@ describe('ReactHooksWithNoopRenderer', () => {
16131606
// As a result we, somewhat surprisingly, commit them in the opposite order.
16141607
// This should be fine because any non-discrete set of work doesn't guarantee order
16151608
// and easily could've happened slightly later too.
1616-
if (gate(flags => flags.enableUnifiedSyncLane)) {
1617-
assertLog(['Will set count to 1', 'Count: 1']);
1618-
} else {
1619-
assertLog(['Will set count to 1', 'Count: 2', 'Count: 1']);
1620-
}
1609+
assertLog(['Will set count to 1', 'Count: 1']);
16211610

16221611
expect(ReactNoop).toMatchRenderedOutput(<span prop="Count: 1" />);
16231612
});

0 commit comments

Comments
 (0)