@@ -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,12 +155,14 @@ import {
156155 markRootPinged ,
157156 markRootExpired ,
158157 markRootFinished ,
159- lanePriorityToSchedulerPriority ,
160158 areLanesExpired ,
159+ getHighestPriorityLane ,
161160} from './ReactFiberLane.new' ;
162161import {
163162 DiscreteEventPriority ,
163+ ContinuousEventPriority ,
164164 DefaultEventPriority ,
165+ IdleEventPriority ,
165166 getCurrentUpdatePriority ,
166167 setCurrentUpdatePriority ,
167168 higherEventPriority ,
@@ -653,19 +654,20 @@ function ensureRootIsScheduled(root: FiberRoot, currentTime: number) {
653654 root ,
654655 root === workInProgressRoot ? workInProgressRootRenderLanes : NoLanes ,
655656 ) ;
656- // This returns the priority level computed during the `getNextLanes` call.
657- const newCallbackPriority = returnNextLanesPriority ( ) ;
658657
659658 if ( nextLanes === NoLanes ) {
660659 // Special case: There's nothing to work on.
661660 if ( existingCallbackNode !== null ) {
662661 cancelCallback ( existingCallbackNode ) ;
663662 }
664663 root . callbackNode = null ;
665- root . callbackPriority = NoLanePriority ;
664+ root . callbackPriority = NoLane ;
666665 return ;
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.
670672 const existingCallbackPriority = root . callbackPriority ;
671673 if ( existingCallbackPriority === newCallbackPriority ) {
@@ -675,7 +677,7 @@ function ensureRootIsScheduled(root: FiberRoot, currentTime: number) {
675677 // TODO: Temporary until we confirm this warning is not fired.
676678 if (
677679 existingCallbackNode == null &&
678- existingCallbackPriority !== SyncLanePriority
680+ existingCallbackPriority !== SyncLane
679681 ) {
680682 console . 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
699701 scheduleSyncCallback ( 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.
17461763 root . 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