Skip to content

Commit

Permalink
Add a separate feature flag
Browse files Browse the repository at this point in the history
  • Loading branch information
tyao1 committed Nov 29, 2022
1 parent df90b2b commit 1abb404
Show file tree
Hide file tree
Showing 23 changed files with 38 additions and 27 deletions.
6 changes: 3 additions & 3 deletions packages/react-dom/src/__tests__/ReactDOMFiberAsync-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,15 +275,15 @@ describe('ReactDOMFiberAsync', () => {
expect(ops).toEqual([]);
});
// Only the active updates have flushed
if (gate(flags => flags.enableSyncDefaultUpdates)) {
if (gate(flags => flags.enableUnifiedSyncLane)) {
expect(container.textContent).toEqual('ABC');
expect(ops).toEqual(['ABC']);
} else {
expect(container.textContent).toEqual('BC');
expect(ops).toEqual(['BC']);
}

if (gate(flags => flags.enableSyncDefaultUpdates)) {
if (gate(flags => flags.enableUnifiedSyncLane)) {
instance.push('D');
expect(container.textContent).toEqual('ABC');
expect(ops).toEqual(['ABC']);
Expand All @@ -296,7 +296,7 @@ describe('ReactDOMFiberAsync', () => {
// Flush the async updates
Scheduler.unstable_flushAll();
expect(container.textContent).toEqual('ABCD');
if (gate(flags => flags.enableSyncDefaultUpdates)) {
if (gate(flags => flags.enableUnifiedSyncLane)) {
expect(ops).toEqual(['ABC', 'ABCD']);
} else {
expect(ops).toEqual(['BC', 'ABCD']);
Expand Down
8 changes: 4 additions & 4 deletions packages/react-reconciler/src/ReactFiberLane.new.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
enableUpdaterTracking,
allowConcurrentByDefault,
enableTransitionTracing,
enableSyncDefaultUpdates,
enableUnifiedSyncLane,
} from 'shared/ReactFeatureFlags';
import {isDevToolsPresent} from './ReactFiberDevToolsHook.new';
import {ConcurrentUpdatesByDefaultMode, NoMode} from './ReactTypeOfMode';
Expand Down Expand Up @@ -136,7 +136,7 @@ let nextRetryLane: Lane = RetryLane1;
function getHighestPriorityLanes(lanes: Lanes | Lane): Lanes {
switch (getHighestPriorityLane(lanes)) {
case SyncHydrationLane:
if (enableSyncDefaultUpdates) {
if (enableUnifiedSyncLane) {
let ret = SyncHydrationLane;
if (lanes & DefaultHydrationLane) {
ret |= DefaultHydrationLane;
Expand All @@ -148,7 +148,7 @@ function getHighestPriorityLanes(lanes: Lanes | Lane): Lanes {
}
return SyncHydrationLane;
case SyncLane:
if (enableSyncDefaultUpdates) {
if (enableUnifiedSyncLane) {
let ret = SyncLane;
if (lanes & DefaultLane) {
ret |= DefaultLane;
Expand Down Expand Up @@ -273,7 +273,7 @@ export function getNextLanes(root: FiberRoot, wipLanes: Lanes): Lanes {
// only difference between default updates and transition updates is that
// default updates do not support refresh transitions.
// Interrupt transtion if default is batched with sync.
(!enableSyncDefaultUpdates &&
(!enableUnifiedSyncLane &&
nextLane === DefaultLane &&
(wipLane & TransitionLanes) !== NoLanes)
) {
Expand Down
8 changes: 4 additions & 4 deletions packages/react-reconciler/src/ReactFiberLane.old.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
enableUpdaterTracking,
allowConcurrentByDefault,
enableTransitionTracing,
enableSyncDefaultUpdates,
enableUnifiedSyncLane,
} from 'shared/ReactFeatureFlags';
import {isDevToolsPresent} from './ReactFiberDevToolsHook.old';
import {ConcurrentUpdatesByDefaultMode, NoMode} from './ReactTypeOfMode';
Expand Down Expand Up @@ -136,7 +136,7 @@ let nextRetryLane: Lane = RetryLane1;
function getHighestPriorityLanes(lanes: Lanes | Lane): Lanes {
switch (getHighestPriorityLane(lanes)) {
case SyncHydrationLane:
if (enableSyncDefaultUpdates) {
if (enableUnifiedSyncLane) {
let ret = SyncHydrationLane;
if (lanes & DefaultHydrationLane) {
ret |= DefaultHydrationLane;
Expand All @@ -148,7 +148,7 @@ function getHighestPriorityLanes(lanes: Lanes | Lane): Lanes {
}
return SyncHydrationLane;
case SyncLane:
if (enableSyncDefaultUpdates) {
if (enableUnifiedSyncLane) {
let ret = SyncLane;
if (lanes & DefaultLane) {
ret |= DefaultLane;
Expand Down Expand Up @@ -273,7 +273,7 @@ export function getNextLanes(root: FiberRoot, wipLanes: Lanes): Lanes {
// only difference between default updates and transition updates is that
// default updates do not support refresh transitions.
// Interrupt transtion if default is batched with sync.
(!enableSyncDefaultUpdates &&
(!enableUnifiedSyncLane &&
nextLane === DefaultLane &&
(wipLane & TransitionLanes) !== NoLanes)
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ describe('ReactBlockingMode', () => {
);

// Now flush the first update
if (gate(flags => flags.enableSyncDefaultUpdates)) {
if (gate(flags => flags.enableUnifiedSyncLane)) {
expect(Scheduler).toHaveYielded(['A1', 'B1']);
expect(root).toMatchRenderedOutput('A1B1');
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ describe('ReactClassSetStateCallback', () => {
expect(Scheduler).toHaveYielded([0]);

await act(async () => {
if (gate(flags => flags.enableSyncDefaultUpdates)) {
if (gate(flags => flags.enableUnifiedSyncLane)) {
React.startTransition(() => {
app.setState({step: 1}, () =>
Scheduler.unstable_yieldValue('Callback 1'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ describe('ReactFlushSync', () => {
// They should commit in two separate batches. First the sync one.
expect(() => {
expect(Scheduler).toFlushUntilNextPaint(
gate(flags => flags.enableSyncDefaultUpdates) ? ['1, 1'] : ['1, 0'],
gate(flags => flags.enableUnifiedSyncLane) ? ['1, 1'] : ['1, 0'],
);
}).toErrorDev('flushSync was called from inside a lifecycle method');

// The remaining update is not sync
ReactNoop.flushSync();
expect(Scheduler).toHaveYielded([]);

if (gate(flags => flags.enableSyncDefaultUpdates)) {
if (gate(flags => flags.enableUnifiedSyncLane)) {
expect(Scheduler).toFlushUntilNextPaint([]);
} else {
// Now flush it.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ describe('ReactHooks', () => {
});
};

if (gate(flags => flags.enableSyncDefaultUpdates)) {
if (gate(flags => flags.enableUnifiedSyncLane)) {
// Update at transition priority
React.startTransition(() => update(n => n * 100));
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1910,7 +1910,7 @@ describe('ReactIncremental', () => {
<ShowBoth />
</Intl>,
);
if (gate(flags => flags.enableSyncDefaultUpdates)) {
if (gate(flags => flags.enableUnifiedSyncLane)) {
expect(Scheduler).toFlushAndYield([
'Intl {}',
'ShowLocale {"locale":"en"}',
Expand Down Expand Up @@ -2774,7 +2774,7 @@ describe('ReactIncremental', () => {
// Interrupt at same priority
ReactNoop.render(<Parent step={2} />);

if (gate(flags => flags.enableSyncDefaultUpdates)) {
if (gate(flags => flags.enableUnifiedSyncLane)) {
expect(Scheduler).toFlushAndYield(['Parent: 2', 'Child: 2']);
} else {
expect(Scheduler).toFlushAndYield(['Child: 1', 'Parent: 2', 'Child: 2']);
Expand Down Expand Up @@ -2805,7 +2805,7 @@ describe('ReactIncremental', () => {
ReactNoop.expire(2000);
ReactNoop.render(<Parent step={2} />);

if (gate(flags => flags.enableSyncDefaultUpdates)) {
if (gate(flags => flags.enableUnifiedSyncLane)) {
expect(Scheduler).toFlushAndYield(['Parent: 2', 'Child: 2']);
} else {
expect(Scheduler).toFlushAndYield(['Child: 1', 'Parent: 2', 'Child: 2']);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ describe('ReactIncrementalUpdates', () => {
// Now flush the remaining work. Even though e and f were already processed,
// they should be processed again, to ensure that the terminal state
// is deterministic.
if (gate(flags => flags.enableSyncDefaultUpdates)) {
if (gate(flags => flags.enableUnifiedSyncLane)) {
expect(Scheduler).toFlushAndYield([
// Then we'll re-process everything for 'g'.
'a',
Expand Down Expand Up @@ -311,7 +311,7 @@ describe('ReactIncrementalUpdates', () => {
// Now flush the remaining work. Even though e and f were already processed,
// they should be processed again, to ensure that the terminal state
// is deterministic.
if (gate(flags => flags.enableSyncDefaultUpdates)) {
if (gate(flags => flags.enableUnifiedSyncLane)) {
expect(Scheduler).toFlushAndYield([
// Then we'll re-process everything for 'g'.
'a',
Expand Down Expand Up @@ -714,7 +714,7 @@ describe('ReactIncrementalUpdates', () => {
pushToLog('B'),
);
});
if (gate(flags => flags.enableSyncDefaultUpdates)) {
if (gate(flags => flags.enableUnifiedSyncLane)) {
expect(Scheduler).toHaveYielded([
'Committed: B',
'Committed: BCD',
Expand Down Expand Up @@ -782,7 +782,7 @@ describe('ReactIncrementalUpdates', () => {
pushToLog('B'),
);
});
if (gate(flags => flags.enableSyncDefaultUpdates)) {
if (gate(flags => flags.enableUnifiedSyncLane)) {
expect(Scheduler).toHaveYielded([
'Committed: B',
'Committed: BCD',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,7 @@ describe('ReactOffscreen', () => {
);

// Before the inner update can finish, we receive another pair of updates.
if (gate(flags => flags.enableSyncDefaultUpdates)) {
if (gate(flags => flags.enableUnifiedSyncLane)) {
React.startTransition(() => {
setOuter(2);
setInner(2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -934,7 +934,7 @@ describe('ReactTransition', () => {
updateNormalPri();
});

if (gate(flags => flags.enableSyncDefaultUpdates)) {
if (gate(flags => flags.enableUnifiedSyncLane)) {
expect(Scheduler).toHaveYielded([
// Interrupt transition.
'Transition pri: 0',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1558,7 +1558,7 @@ describe('useMutableSource', () => {
expect(Scheduler).toFlushAndYieldThrough(['a0', 'b0']);
// Mutate in an event. This schedules a subscription update on a, which
// already mounted, but not b, which hasn't subscribed yet.
if (gate(flags => flags.enableSyncDefaultUpdates)) {
if (gate(flags => flags.enableUnifiedSyncLane)) {
React.startTransition(() => {
mutateA('a1');
mutateB('b1');
Expand Down
2 changes: 2 additions & 0 deletions packages/shared/ReactFeatureFlags.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ export const enableUseRefAccessWarning = false;
// Enables time slicing for updates that aren't wrapped in startTransition.
export const enableSyncDefaultUpdates = true;

export const enableUnifiedSyncLane = __EXPERIMENTAL__;

// Adds an opt-in to time slicing for updates that aren't wrapped in
// startTransition. Only relevant when enableSyncDefaultUpdates is disabled.
export const allowConcurrentByDefault = false;
Expand Down
1 change: 1 addition & 0 deletions packages/shared/forks/ReactFeatureFlags.native-fb.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export const disableSchedulerTimeoutInWorkLoop = false;
export const enableLazyContextPropagation = false;
export const enableLegacyHidden = true;
export const enableSyncDefaultUpdates = true;
export const enableUnifiedSyncLane = false;
export const allowConcurrentByDefault = true;
export const enableCustomElementPropertySupport = false;

Expand Down
1 change: 1 addition & 0 deletions packages/shared/forks/ReactFeatureFlags.native-oss.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export const disableSchedulerTimeoutInWorkLoop = false;
export const enableLazyContextPropagation = false;
export const enableLegacyHidden = false;
export const enableSyncDefaultUpdates = true;
export const enableUnifiedSyncLane = false;
export const allowConcurrentByDefault = false;
export const enableCustomElementPropertySupport = false;

Expand Down
1 change: 1 addition & 0 deletions packages/shared/forks/ReactFeatureFlags.test-renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export const disableSchedulerTimeoutInWorkLoop = false;
export const enableLazyContextPropagation = false;
export const enableLegacyHidden = false;
export const enableSyncDefaultUpdates = true;
export const enableUnifiedSyncLane = __EXPERIMENTAL__;
export const allowConcurrentByDefault = false;
export const enableCustomElementPropertySupport = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export const disableSchedulerTimeoutInWorkLoop = false;
export const enableLazyContextPropagation = false;
export const enableLegacyHidden = false;
export const enableSyncDefaultUpdates = true;
export const enableUnifiedSyncLane = false;
export const allowConcurrentByDefault = true;

export const consoleManagedByDevToolsDuringStrictMode = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export const disableSchedulerTimeoutInWorkLoop = false;
export const enableLazyContextPropagation = false;
export const enableLegacyHidden = false;
export const enableSyncDefaultUpdates = true;
export const enableUnifiedSyncLane = false;
export const allowConcurrentByDefault = true;
export const enableCustomElementPropertySupport = false;

Expand Down
1 change: 1 addition & 0 deletions packages/shared/forks/ReactFeatureFlags.testing.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export const disableSchedulerTimeoutInWorkLoop = false;
export const enableLazyContextPropagation = false;
export const enableLegacyHidden = false;
export const enableSyncDefaultUpdates = true;
export const enableUnifiedSyncLane = __EXPERIMENTAL__;
export const allowConcurrentByDefault = false;
export const enableCustomElementPropertySupport = false;

Expand Down
1 change: 1 addition & 0 deletions packages/shared/forks/ReactFeatureFlags.testing.www.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export const disableSchedulerTimeoutInWorkLoop = false;
export const enableLazyContextPropagation = false;
export const enableLegacyHidden = false;
export const enableSyncDefaultUpdates = true;
export const enableUnifiedSyncLane = __EXPERIMENTAL__;
export const allowConcurrentByDefault = true;
export const enableCustomElementPropertySupport = false;

Expand Down
1 change: 1 addition & 0 deletions packages/shared/forks/ReactFeatureFlags.www-dynamic.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const enableProfilerNestedUpdateScheduledHook = __VARIANT__;
export const disableSchedulerTimeoutInWorkLoop = __VARIANT__;
export const enableLazyContextPropagation = __VARIANT__;
export const enableSyncDefaultUpdates = __VARIANT__;
export const enableUnifiedSyncLane = __VARIANT__;
export const consoleManagedByDevToolsDuringStrictMode = __VARIANT__;
export const enableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay = __VARIANT__;
export const enableClientRenderFallbackOnTextMismatch = __VARIANT__;
Expand Down
1 change: 1 addition & 0 deletions packages/shared/forks/ReactFeatureFlags.www.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export const {
disableSchedulerTimeoutInWorkLoop,
enableLazyContextPropagation,
enableSyncDefaultUpdates,
enableUnifiedSyncLane,
enableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay,
enableClientRenderFallbackOnTextMismatch,
enableTransitionTracing,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ describe('useSubscription', () => {
observableA.next('a-2');

// Update again
if (gate(flags => flags.enableSyncDefaultUpdates)) {
if (gate(flags => flags.enableUnifiedSyncLane)) {
React.startTransition(() => {
renderer.update(<Parent observed={observableA} />);
});
Expand Down

0 comments on commit 1abb404

Please sign in to comment.