@@ -32,6 +32,7 @@ import {
32
32
disableSchedulerTimeoutInWorkLoop ,
33
33
enableStrictEffects ,
34
34
skipUnmountedBoundaries ,
35
+ enableSyncDefaultUpdates ,
35
36
enableUpdaterTracking ,
36
37
} from 'shared/ReactFeatureFlags' ;
37
38
import ReactSharedInternals from 'shared/ReactSharedInternals' ;
@@ -138,6 +139,10 @@ import {
138
139
NoLanes ,
139
140
NoLane ,
140
141
SyncLane ,
142
+ DefaultLane ,
143
+ DefaultHydrationLane ,
144
+ InputContinuousLane ,
145
+ InputContinuousHydrationLane ,
141
146
NoTimestamp ,
142
147
claimNextTransitionLane ,
143
148
claimNextRetryLane ,
@@ -433,6 +438,13 @@ export function requestUpdateLane(fiber: Fiber): Lane {
433
438
// TODO: Move this type conversion to the event priority module.
434
439
const updateLane : Lane = ( getCurrentUpdatePriority ( ) : any ) ;
435
440
if ( updateLane !== NoLane ) {
441
+ if (
442
+ enableSyncDefaultUpdates &&
443
+ ( updateLane === InputContinuousLane ||
444
+ updateLane === InputContinuousHydrationLane )
445
+ ) {
446
+ return DefaultLane ;
447
+ }
436
448
return updateLane;
437
449
}
438
450
@@ -443,6 +455,13 @@ export function requestUpdateLane(fiber: Fiber): Lane {
443
455
// use that directly.
444
456
// TODO: Move this type conversion to the event priority module.
445
457
const eventLane : Lane = ( getCurrentEventPriority ( ) : any ) ;
458
+ if (
459
+ enableSyncDefaultUpdates &&
460
+ ( eventLane === InputContinuousLane ||
461
+ eventLane === InputContinuousHydrationLane )
462
+ ) {
463
+ return DefaultLane ;
464
+ }
446
465
return eventLane;
447
466
}
448
467
@@ -695,7 +714,16 @@ function ensureRootIsScheduled(root: FiberRoot, currentTime: number) {
695
714
696
715
// Schedule a new callback.
697
716
let newCallbackNode;
698
- if (newCallbackPriority === SyncLane) {
717
+ if (
718
+ enableSyncDefaultUpdates &&
719
+ ( newCallbackPriority === DefaultLane ||
720
+ newCallbackPriority === DefaultHydrationLane )
721
+ ) {
722
+ newCallbackNode = scheduleCallback (
723
+ ImmediateSchedulerPriority ,
724
+ performSyncWorkOnRoot . bind ( null , root ) ,
725
+ ) ;
726
+ } else if (newCallbackPriority === SyncLane) {
699
727
// Special case: Sync React callbacks are scheduled on a special
700
728
// internal queue
701
729
scheduleSyncCallback ( performSyncWorkOnRoot . bind ( null , root ) ) ;
@@ -1030,7 +1058,11 @@ function performSyncWorkOnRoot(root) {
1030
1058
const finishedWork : Fiber = ( root . current . alternate : any ) ;
1031
1059
root . finishedWork = finishedWork ;
1032
1060
root . finishedLanes = lanes ;
1033
- commitRoot ( root ) ;
1061
+ if ( enableSyncDefaultUpdates && ! includesSomeLane ( lanes , SyncLane ) ) {
1062
+ finishConcurrentRender ( root , exitStatus , lanes ) ;
1063
+ } else {
1064
+ commitRoot ( root ) ;
1065
+ }
1034
1066
1035
1067
// Before exiting, make sure there's a callback scheduled for the next
1036
1068
// pending level.
0 commit comments