Skip to content

Commit 9564fcd

Browse files
author
Jack Pope
committed
Clean up enableUnifiedSyncLane
1 parent 7608516 commit 9564fcd

19 files changed

+49
-220
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
});

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

+17-107
Original file line numberDiff line numberDiff line change
@@ -156,13 +156,7 @@ describe('ReactIncrementalUpdates', () => {
156156
}
157157

158158
// Schedule some async updates
159-
if (
160-
gate(
161-
flags =>
162-
!flags.forceConcurrentByDefaultForTesting ||
163-
flags.enableUnifiedSyncLane,
164-
)
165-
) {
159+
if (gate(flags => !flags.forceConcurrentByDefaultForTesting)) {
166160
React.startTransition(() => {
167161
instance.setState(createUpdate('a'));
168162
instance.setState(createUpdate('b'));
@@ -189,13 +183,7 @@ describe('ReactIncrementalUpdates', () => {
189183
});
190184

191185
// The sync updates should have flushed, but not the async ones.
192-
if (
193-
gate(
194-
flags =>
195-
!flags.forceConcurrentByDefaultForTesting &&
196-
flags.enableUnifiedSyncLane,
197-
)
198-
) {
186+
if (gate(flags => !flags.forceConcurrentByDefaultForTesting)) {
199187
assertLog(['d', 'e', 'f']);
200188
expect(ReactNoop).toMatchRenderedOutput(<span prop="def" />);
201189
} else {
@@ -207,40 +195,16 @@ describe('ReactIncrementalUpdates', () => {
207195
// Now flush the remaining work. Even though e and f were already processed,
208196
// they should be processed again, to ensure that the terminal state
209197
// is deterministic.
210-
if (
211-
gate(
212-
flags =>
213-
!flags.forceConcurrentByDefaultForTesting &&
214-
!flags.enableUnifiedSyncLane,
215-
)
216-
) {
217-
await waitForAll([
218-
// Since 'g' is in a transition, we'll process 'd' separately first.
219-
// That causes us to process 'd' with 'e' and 'f' rebased.
220-
'd',
221-
'e',
222-
'f',
223-
// Then we'll re-process everything for 'g'.
224-
'a',
225-
'b',
226-
'c',
227-
'd',
228-
'e',
229-
'f',
230-
'g',
231-
]);
232-
} else {
233-
await waitForAll([
234-
// Then we'll re-process everything for 'g'.
235-
'a',
236-
'b',
237-
'c',
238-
'd',
239-
'e',
240-
'f',
241-
'g',
242-
]);
243-
}
198+
await waitForAll([
199+
// Then we'll re-process everything for 'g'.
200+
'a',
201+
'b',
202+
'c',
203+
'd',
204+
'e',
205+
'f',
206+
'g',
207+
]);
244208
expect(ReactNoop).toMatchRenderedOutput(<span prop="abcdefg" />);
245209
});
246210

@@ -267,13 +231,7 @@ describe('ReactIncrementalUpdates', () => {
267231
}
268232

269233
// Schedule some async updates
270-
if (
271-
gate(
272-
flags =>
273-
!flags.forceConcurrentByDefaultForTesting ||
274-
flags.enableUnifiedSyncLane,
275-
)
276-
) {
234+
if (gate(flags => !flags.forceConcurrentByDefaultForTesting)) {
277235
React.startTransition(() => {
278236
instance.setState(createUpdate('a'));
279237
instance.setState(createUpdate('b'));
@@ -303,13 +261,7 @@ describe('ReactIncrementalUpdates', () => {
303261
});
304262

305263
// The sync updates should have flushed, but not the async ones.
306-
if (
307-
gate(
308-
flags =>
309-
!flags.forceConcurrentByDefaultForTesting &&
310-
flags.enableUnifiedSyncLane,
311-
)
312-
) {
264+
if (gate(flags => !flags.forceConcurrentByDefaultForTesting)) {
313265
assertLog(['d', 'e', 'f']);
314266
} else {
315267
// Update d was dropped and replaced by e.
@@ -320,13 +272,7 @@ describe('ReactIncrementalUpdates', () => {
320272
// Now flush the remaining work. Even though e and f were already processed,
321273
// they should be processed again, to ensure that the terminal state
322274
// is deterministic.
323-
if (
324-
gate(
325-
flags =>
326-
!flags.forceConcurrentByDefaultForTesting &&
327-
!flags.enableUnifiedSyncLane,
328-
)
329-
) {
275+
if (gate(flags => !flags.forceConcurrentByDefaultForTesting)) {
330276
await waitForAll([
331277
// Since 'g' is in a transition, we'll process 'd' separately first.
332278
// That causes us to process 'd' with 'e' and 'f' rebased.
@@ -684,25 +630,7 @@ describe('ReactIncrementalUpdates', () => {
684630
pushToLog('B'),
685631
);
686632
});
687-
if (gate(flags => flags.enableUnifiedSyncLane)) {
688-
assertLog(['Committed: B', 'Committed: BCD', 'Committed: ABCD']);
689-
} else {
690-
assertLog([
691-
// A and B are pending. B is higher priority, so we'll render that first.
692-
'Committed: B',
693-
// Because A comes first in the queue, we're now in rebase mode. B must
694-
// be rebased on top of A. Also, in a layout effect, we received two new
695-
// updates: C and D. C is user-blocking and D is synchronous.
696-
//
697-
// First render the synchronous update. What we're testing here is that
698-
// B *is not dropped* even though it has lower than sync priority. That's
699-
// because we already committed it. However, this render should not
700-
// include C, because that update wasn't already committed.
701-
'Committed: BD',
702-
'Committed: BCD',
703-
'Committed: ABCD',
704-
]);
705-
}
633+
assertLog(['Committed: B', 'Committed: BCD', 'Committed: ABCD']);
706634
expect(root).toMatchRenderedOutput('ABCD');
707635
});
708636

@@ -744,25 +672,7 @@ describe('ReactIncrementalUpdates', () => {
744672
pushToLog('B'),
745673
);
746674
});
747-
if (gate(flags => flags.enableUnifiedSyncLane)) {
748-
assertLog(['Committed: B', 'Committed: BCD', 'Committed: ABCD']);
749-
} else {
750-
assertLog([
751-
// A and B are pending. B is higher priority, so we'll render that first.
752-
'Committed: B',
753-
// Because A comes first in the queue, we're now in rebase mode. B must
754-
// be rebased on top of A. Also, in a layout effect, we received two new
755-
// updates: C and D. C is user-blocking and D is synchronous.
756-
//
757-
// First render the synchronous update. What we're testing here is that
758-
// B *is not dropped* even though it has lower than sync priority. That's
759-
// because we already committed it. However, this render should not
760-
// include C, because that update wasn't already committed.
761-
'Committed: BD',
762-
'Committed: BCD',
763-
'Committed: ABCD',
764-
]);
765-
}
675+
assertLog(['Committed: B', 'Committed: BCD', 'Committed: ABCD']);
766676
expect(root).toMatchRenderedOutput('ABCD');
767677
});
768678

0 commit comments

Comments
 (0)