@@ -43,7 +43,9 @@ import {
4343 requestPaint ,
4444 now ,
4545 ImmediatePriority as ImmediateSchedulerPriority ,
46+ UserBlockingPriority as UserBlockingSchedulerPriority ,
4647 NormalPriority as NormalSchedulerPriority ,
48+ IdlePriority as IdleSchedulerPriority ,
4749 flushSyncCallbackQueue ,
4850 scheduleSyncCallback ,
4951} from './SchedulerWithReactIntegration.new' ;
@@ -130,8 +132,6 @@ import {
130132 MountLayoutDev ,
131133} from './ReactFiberFlags' ;
132134import {
133- NoLanePriority ,
134- SyncLanePriority ,
135135 NoLanes ,
136136 NoLane ,
137137 SyncLane ,
@@ -147,7 +147,6 @@ import {
147147 includesOnlyRetries ,
148148 includesOnlyTransitions ,
149149 getNextLanes ,
150- returnNextLanesPriority ,
151150 markStarvedLanesAsExpired ,
152151 getLanesToRetrySynchronouslyOnError ,
153152 getMostRecentEventTime ,
@@ -156,11 +155,13 @@ import {
156155 markRootPinged ,
157156 markRootExpired ,
158157 markRootFinished ,
159- lanePriorityToSchedulerPriority ,
158+ getHighestPriorityLane ,
160159} from './ReactFiberLane.new' ;
161160import {
162161 DiscreteEventPriority ,
162+ ContinuousEventPriority ,
163163 DefaultEventPriority ,
164+ IdleEventPriority ,
164165 getCurrentUpdatePriority ,
165166 setCurrentUpdatePriority ,
166167 higherEventPriority ,
@@ -652,19 +653,20 @@ function ensureRootIsScheduled(root: FiberRoot, currentTime: number) {
652653 root ,
653654 root === workInProgressRoot ? workInProgressRootRenderLanes : NoLanes ,
654655 ) ;
655- // This returns the priority level computed during the `getNextLanes` call.
656- const newCallbackPriority = returnNextLanesPriority ( ) ;
657656
658657 if ( nextLanes === NoLanes ) {
659658 // Special case: There's nothing to work on.
660659 if ( existingCallbackNode !== null ) {
661660 cancelCallback ( existingCallbackNode ) ;
662661 }
663662 root . callbackNode = null ;
664- root . callbackPriority = NoLanePriority ;
663+ root . callbackPriority = NoLane ;
665664 return ;
666665 }
667666
667+ // We use the highest priority lane to represent the priority of the callback.
668+ const newCallbackPriority = getHighestPriorityLane ( nextLanes ) ;
669+
668670 // Check if there's an existing task. We may be able to reuse it.
669671 const existingCallbackPriority = root . callbackPriority ;
670672 if ( existingCallbackPriority === newCallbackPriority ) {
@@ -674,7 +676,7 @@ function ensureRootIsScheduled(root: FiberRoot, currentTime: number) {
674676 // TODO: Temporary until we confirm this warning is not fired.
675677 if (
676678 existingCallbackNode == null &&
677- existingCallbackPriority !== SyncLanePriority
679+ existingCallbackPriority !== SyncLane
678680 ) {
679681 console . error (
680682 'Expected scheduled callback to exist. This error is likely caused by a bug in React. Please file an issue.' ,
@@ -692,7 +694,7 @@ function ensureRootIsScheduled(root: FiberRoot, currentTime: number) {
692694
693695 // Schedule a new callback.
694696 let newCallbackNode;
695- if (newCallbackPriority === SyncLanePriority ) {
697+ if (newCallbackPriority === SyncLane ) {
696698 // Special case: Sync React callbacks are scheduled on a special
697699 // internal queue
698700 scheduleSyncCallback ( performSyncWorkOnRoot . bind ( null , root ) ) ;
@@ -705,9 +707,24 @@ function ensureRootIsScheduled(root: FiberRoot, currentTime: number) {
705707 }
706708 newCallbackNode = null;
707709 } else {
708- const schedulerPriorityLevel = lanePriorityToSchedulerPriority (
709- newCallbackPriority ,
710- ) ;
710+ let schedulerPriorityLevel ;
711+ switch ( lanesToEventPriority ( nextLanes ) ) {
712+ case DiscreteEventPriority :
713+ schedulerPriorityLevel = ImmediateSchedulerPriority ;
714+ break ;
715+ case ContinuousEventPriority :
716+ schedulerPriorityLevel = UserBlockingSchedulerPriority ;
717+ break ;
718+ case DefaultEventPriority :
719+ schedulerPriorityLevel = NormalSchedulerPriority ;
720+ break ;
721+ case IdleEventPriority :
722+ schedulerPriorityLevel = IdleSchedulerPriority ;
723+ break ;
724+ default :
725+ schedulerPriorityLevel = NormalSchedulerPriority ;
726+ break ;
727+ }
711728 newCallbackNode = scheduleCallback(
712729 schedulerPriorityLevel,
713730 performConcurrentWorkOnRoot.bind(null, root),
@@ -1739,7 +1756,7 @@ function commitRootImpl(root, renderPriorityLevel) {
17391756 // commitRoot never returns a continuation; it always finishes synchronously.
17401757 // So we can clear these now to allow a new callback to be scheduled.
17411758 root . callbackNode = null ;
1742- root . callbackPriority = NoLanePriority ;
1759+ root . callbackPriority = NoLane ;
17431760
17441761 // Update the first and last pending times on this root. The new first
17451762 // pending time is whatever is left on the root fiber.
0 commit comments