@@ -43,7 +43,9 @@ import {
4343requestPaint ,
4444now ,
4545ImmediatePriority as ImmediateSchedulerPriority ,
46+ UserBlockingPriority as UserBlockingSchedulerPriority ,
4647NormalPriority as NormalSchedulerPriority ,
48+ IdlePriority as IdleSchedulerPriority ,
4749flushSyncCallbackQueue ,
4850scheduleSyncCallback ,
4951} from './SchedulerWithReactIntegration.new' ;
@@ -130,8 +132,6 @@ import {
130132MountLayoutDev ,
131133} from './ReactFiberFlags' ;
132134import {
133- NoLanePriority ,
134- SyncLanePriority ,
135135NoLanes ,
136136NoLane ,
137137SyncLane ,
@@ -147,7 +147,6 @@ import {
147147includesOnlyRetries ,
148148includesOnlyTransitions ,
149149getNextLanes ,
150- returnNextLanesPriority ,
151150markStarvedLanesAsExpired ,
152151getLanesToRetrySynchronouslyOnError ,
153152getMostRecentEventTime ,
@@ -156,12 +155,14 @@ import {
156155markRootPinged ,
157156markRootExpired ,
158157markRootFinished ,
159- lanePriorityToSchedulerPriority ,
160158areLanesExpired ,
159+ getHighestPriorityLane ,
161160} from './ReactFiberLane.new' ;
162161import {
163162DiscreteEventPriority ,
163+ ContinuousEventPriority ,
164164DefaultEventPriority ,
165+ IdleEventPriority ,
165166getCurrentUpdatePriority ,
166167setCurrentUpdatePriority ,
167168higherEventPriority ,
@@ -653,19 +654,20 @@ function ensureRootIsScheduled(root: FiberRoot, currentTime: number) {
653654root ,
654655root === workInProgressRoot ? workInProgressRootRenderLanes : NoLanes ,
655656) ;
656- // This returns the priority level computed during the `getNextLanes` call.
657- const newCallbackPriority = returnNextLanesPriority ( ) ;
658657
659658if ( nextLanes === NoLanes ) {
660659// Special case: There's nothing to work on.
661660if ( existingCallbackNode !== null ) {
662661cancelCallback ( existingCallbackNode ) ;
663662}
664663root . callbackNode = null ;
665- root . callbackPriority = NoLanePriority ;
664+ root . callbackPriority = NoLane ;
666665return ;
667666}
668667
668+ // We use the highest priority lane to represent the priority of the callback.
669+ const newCallbackPriority = getHighestPriorityLane ( nextLanes ) ;
670+
669671// Check if there's an existing task. We may be able to reuse it.
670672const existingCallbackPriority = root . callbackPriority ;
671673if ( existingCallbackPriority === newCallbackPriority ) {
@@ -675,7 +677,7 @@ function ensureRootIsScheduled(root: FiberRoot, currentTime: number) {
675677// TODO: Temporary until we confirm this warning is not fired.
676678if (
677679existingCallbackNode == null &&
678- existingCallbackPriority !== SyncLanePriority
680+ existingCallbackPriority !== SyncLane
679681) {
680682console . error (
681683'Expected scheduled callback to exist. This error is likely caused by a bug in React. Please file an issue.' ,
@@ -693,7 +695,7 @@ function ensureRootIsScheduled(root: FiberRoot, currentTime: number) {
693695
694696 // Schedule a new callback.
695697 let newCallbackNode;
696- if (newCallbackPriority === SyncLanePriority ) {
698+ if (newCallbackPriority === SyncLane ) {
697699// Special case: Sync React callbacks are scheduled on a special
698700// internal queue
699701scheduleSyncCallback ( performSyncWorkOnRoot . bind ( null , root ) ) ;
@@ -706,9 +708,24 @@ function ensureRootIsScheduled(root: FiberRoot, currentTime: number) {
706708}
707709 newCallbackNode = null;
708710} else {
709- const schedulerPriorityLevel = lanePriorityToSchedulerPriority (
710- newCallbackPriority ,
711- ) ;
711+ let schedulerPriorityLevel ;
712+ switch ( lanesToEventPriority ( nextLanes ) ) {
713+ case DiscreteEventPriority :
714+ schedulerPriorityLevel = ImmediateSchedulerPriority ;
715+ break ;
716+ case ContinuousEventPriority :
717+ schedulerPriorityLevel = UserBlockingSchedulerPriority ;
718+ break ;
719+ case DefaultEventPriority :
720+ schedulerPriorityLevel = NormalSchedulerPriority ;
721+ break ;
722+ case IdleEventPriority :
723+ schedulerPriorityLevel = IdleSchedulerPriority ;
724+ break ;
725+ default :
726+ schedulerPriorityLevel = NormalSchedulerPriority ;
727+ break ;
728+ }
712729 newCallbackNode = scheduleCallback(
713730 schedulerPriorityLevel,
714731 performConcurrentWorkOnRoot.bind(null, root),
@@ -1744,7 +1761,7 @@ function commitRootImpl(root, renderPriorityLevel) {
17441761// commitRoot never returns a continuation; it always finishes synchronously.
17451762// So we can clear these now to allow a new callback to be scheduled.
17461763root . callbackNode = null ;
1747- root . callbackPriority = NoLanePriority ;
1764+ root . callbackPriority = NoLane ;
17481765
17491766// Update the first and last pending times on this root. The new first
17501767// pending time is whatever is left on the root fiber.
0 commit comments