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 e2872ea
Show file tree
Hide file tree
Showing 24 changed files with 145 additions and 148 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 @@ -961,7 +961,7 @@ describe('ReactHooksWithNoopRenderer', () => {
ReactNoop.flushSync(() => {
counter.current.dispatch(INCREMENT);
});
if (gate(flags => flags.enableSyncDefaultUpdates)) {
if (gate(flags => flags.enableUnifiedSyncLane)) {
expect(Scheduler).toHaveYielded(['Count: 4']);
expect(ReactNoop.getChildren()).toEqual([span('Count: 4')]);
} else {
Expand Down Expand Up @@ -1727,7 +1727,7 @@ describe('ReactHooksWithNoopRenderer', () => {
// As a result we, somewhat surprisingly, commit them in the opposite order.
// This should be fine because any non-discrete set of work doesn't guarantee order
// and easily could've happened slightly later too.
if (gate(flags => flags.enableSyncDefaultUpdates)) {
if (gate(flags => flags.enableUnifiedSyncLane)) {
expect(Scheduler).toHaveYielded(['Will set count to 1', 'Count: 1']);
} else {
expect(Scheduler).toHaveYielded([
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
Loading

0 comments on commit e2872ea

Please sign in to comment.