Skip to content

Commit 1cddd39

Browse files
committed
Add enableSyncDefaultUpdates
1 parent d95fd0a commit 1cddd39

14 files changed

+43
-4
lines changed

packages/react-reconciler/src/ReactFiberLane.new.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,11 @@ export type Lane = number;
3636
export type LaneMap<T> = Array<T>;
3737

3838
import invariant from 'shared/invariant';
39-
import {enableCache, enableSchedulingProfiler} from 'shared/ReactFeatureFlags';
39+
import {
40+
enableCache,
41+
enableSchedulingProfiler,
42+
enableSyncDefaultUpdates,
43+
} from 'shared/ReactFeatureFlags';
4044

4145
import {
4246
ImmediatePriority as ImmediateSchedulerPriority,
@@ -541,6 +545,9 @@ export function findUpdateLane(lanePriority: LanePriority): Lane {
541545
case SyncLanePriority:
542546
return SyncLane;
543547
case InputContinuousLanePriority:
548+
if (enableSyncDefaultUpdates) {
549+
return DefaultLanePriority;
550+
}
544551
return InputContinuousLane;
545552
case DefaultLanePriority:
546553
return DefaultLane;

packages/react-reconciler/src/ReactFiberLane.old.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,11 @@ export type Lane = number;
3636
export type LaneMap<T> = Array<T>;
3737

3838
import invariant from 'shared/invariant';
39-
import {enableCache, enableSchedulingProfiler} from 'shared/ReactFeatureFlags';
39+
import {
40+
enableCache,
41+
enableSchedulingProfiler,
42+
enableSyncDefaultUpdates,
43+
} from 'shared/ReactFeatureFlags';
4044

4145
import {
4246
ImmediatePriority as ImmediateSchedulerPriority,
@@ -541,6 +545,9 @@ export function findUpdateLane(lanePriority: LanePriority): Lane {
541545
case SyncLanePriority:
542546
return SyncLane;
543547
case InputContinuousLanePriority:
548+
if (enableSyncDefaultUpdates) {
549+
return DefaultLanePriority;
550+
}
544551
return InputContinuousLane;
545552
case DefaultLanePriority:
546553
return DefaultLane;

packages/react-reconciler/src/ReactFiberWorkLoop.new.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import {
3232
disableSchedulerTimeoutInWorkLoop,
3333
enableStrictEffects,
3434
skipUnmountedBoundaries,
35+
enableSyncDefaultUpdates,
3536
} from 'shared/ReactFeatureFlags';
3637
import ReactSharedInternals from 'shared/ReactSharedInternals';
3738
import invariant from 'shared/invariant';
@@ -684,7 +685,12 @@ function ensureRootIsScheduled(root: FiberRoot, currentTime: number) {
684685

685686
// Schedule a new callback.
686687
let newCallbackNode;
687-
if (newCallbackPriority === SyncLanePriority) {
688+
if (enableSyncDefaultUpdates && newCallbackPriority === DefaultLanePriority) {
689+
newCallbackNode = scheduleCallback(
690+
ImmediateSchedulerPriority,
691+
performSyncWorkOnRoot.bind(null, root),
692+
);
693+
} else if (newCallbackPriority === SyncLanePriority) {
688694
// Special case: Sync React callbacks are scheduled on a special
689695
// internal queue
690696
scheduleSyncCallback(performSyncWorkOnRoot.bind(null, root));

packages/react-reconciler/src/ReactFiberWorkLoop.old.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import {
3232
disableSchedulerTimeoutInWorkLoop,
3333
enableStrictEffects,
3434
skipUnmountedBoundaries,
35+
enableSyncDefaultUpdates,
3536
} from 'shared/ReactFeatureFlags';
3637
import ReactSharedInternals from 'shared/ReactSharedInternals';
3738
import invariant from 'shared/invariant';
@@ -684,7 +685,12 @@ function ensureRootIsScheduled(root: FiberRoot, currentTime: number) {
684685

685686
// Schedule a new callback.
686687
let newCallbackNode;
687-
if (newCallbackPriority === SyncLanePriority) {
688+
if (enableSyncDefaultUpdates && newCallbackPriority === DefaultLanePriority) {
689+
newCallbackNode = scheduleCallback(
690+
ImmediateSchedulerPriority,
691+
performSyncWorkOnRoot.bind(null, root),
692+
);
693+
} else if (newCallbackPriority === SyncLanePriority) {
688694
// Special case: Sync React callbacks are scheduled on a special
689695
// internal queue
690696
scheduleSyncCallback(performSyncWorkOnRoot.bind(null, root));

packages/shared/ReactFeatureFlags.js

+2
Original file line numberDiff line numberDiff line change
@@ -164,3 +164,5 @@ export const enableRecursiveCommitTraversal = false;
164164
export const disableSchedulerTimeoutInWorkLoop = false;
165165

166166
export const enableLazyContextPropagation = false;
167+
168+
export const enableSyncDefaultUpdates = false;

packages/shared/forks/ReactFeatureFlags.native-fb.js

+1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ export const enableUseRefAccessWarning = false;
5959
export const enableRecursiveCommitTraversal = false;
6060
export const disableSchedulerTimeoutInWorkLoop = false;
6161
export const enableLazyContextPropagation = false;
62+
export const enableSyncDefaultUpdates = false;
6263

6364
// Flow magic to verify the exports of this file match the original version.
6465
// eslint-disable-next-line no-unused-vars

packages/shared/forks/ReactFeatureFlags.native-oss.js

+1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ export const enableUseRefAccessWarning = false;
5858
export const enableRecursiveCommitTraversal = false;
5959
export const disableSchedulerTimeoutInWorkLoop = false;
6060
export const enableLazyContextPropagation = false;
61+
export const enableSyncDefaultUpdates = false;
6162

6263
// Flow magic to verify the exports of this file match the original version.
6364
// eslint-disable-next-line no-unused-vars

packages/shared/forks/ReactFeatureFlags.test-renderer.js

+1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ export const enableUseRefAccessWarning = false;
5858
export const enableRecursiveCommitTraversal = false;
5959
export const disableSchedulerTimeoutInWorkLoop = false;
6060
export const enableLazyContextPropagation = false;
61+
export const enableSyncDefaultUpdates = false;
6162

6263
// Flow magic to verify the exports of this file match the original version.
6364
// eslint-disable-next-line no-unused-vars

packages/shared/forks/ReactFeatureFlags.test-renderer.native.js

+1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ export const enableUseRefAccessWarning = false;
5858
export const enableRecursiveCommitTraversal = false;
5959
export const disableSchedulerTimeoutInWorkLoop = false;
6060
export const enableLazyContextPropagation = false;
61+
export const enableSyncDefaultUpdates = false;
6162

6263
// Flow magic to verify the exports of this file match the original version.
6364
// eslint-disable-next-line no-unused-vars

packages/shared/forks/ReactFeatureFlags.test-renderer.www.js

+1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ export const enableUseRefAccessWarning = false;
5858
export const enableRecursiveCommitTraversal = false;
5959
export const disableSchedulerTimeoutInWorkLoop = false;
6060
export const enableLazyContextPropagation = false;
61+
export const enableSyncDefaultUpdates = false;
6162

6263
// Flow magic to verify the exports of this file match the original version.
6364
// eslint-disable-next-line no-unused-vars

packages/shared/forks/ReactFeatureFlags.testing.js

+1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ export const enableUseRefAccessWarning = false;
5858
export const enableRecursiveCommitTraversal = false;
5959
export const disableSchedulerTimeoutInWorkLoop = false;
6060
export const enableLazyContextPropagation = false;
61+
export const enableSyncDefaultUpdates = false;
6162

6263
// Flow magic to verify the exports of this file match the original version.
6364
// eslint-disable-next-line no-unused-vars

packages/shared/forks/ReactFeatureFlags.testing.www.js

+1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ export const enableUseRefAccessWarning = false;
5858
export const enableRecursiveCommitTraversal = false;
5959
export const disableSchedulerTimeoutInWorkLoop = false;
6060
export const enableLazyContextPropagation = false;
61+
export const enableSyncDefaultUpdates = false;
6162

6263
// Flow magic to verify the exports of this file match the original version.
6364
// eslint-disable-next-line no-unused-vars

packages/shared/forks/ReactFeatureFlags.www-dynamic.js

+1
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,4 @@ export const deletedTreeCleanUpLevel = __VARIANT__ ? 3 : 1;
5757
export const enableProfilerNestedUpdateScheduledHook = __VARIANT__;
5858
export const disableSchedulerTimeoutInWorkLoop = __VARIANT__;
5959
export const enableLazyContextPropagation = __VARIANT__;
60+
export const enableSyncDefaultUpdates = __VARIANT__;

packages/shared/forks/ReactFeatureFlags.www.js

+3
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ export const enableNewReconciler = __VARIANT__;
9292

9393
export const enableRecursiveCommitTraversal = false;
9494

95+
// WWW is on the new sync behavior by default unless overridden by roots.
96+
export const enableSyncDefaultUpdates = __VARIANT__;
97+
9598
// Flow magic to verify the exports of this file match the original version.
9699
// eslint-disable-next-line no-unused-vars
97100
type Check<_X, Y: _X, X: Y = _X> = null;

0 commit comments

Comments
 (0)