@@ -43,7 +43,9 @@ import {
43
43
requestPaint ,
44
44
now ,
45
45
ImmediatePriority as ImmediateSchedulerPriority ,
46
+ UserBlockingPriority as UserBlockingSchedulerPriority ,
46
47
NormalPriority as NormalSchedulerPriority ,
48
+ IdlePriority as IdleSchedulerPriority ,
47
49
flushSyncCallbackQueue ,
48
50
scheduleSyncCallback ,
49
51
} from './SchedulerWithReactIntegration.new' ;
@@ -130,8 +132,6 @@ import {
130
132
MountLayoutDev ,
131
133
} from './ReactFiberFlags' ;
132
134
import {
133
- NoLanePriority ,
134
- SyncLanePriority ,
135
135
NoLanes ,
136
136
NoLane ,
137
137
SyncLane ,
@@ -147,7 +147,6 @@ import {
147
147
includesOnlyRetries ,
148
148
includesOnlyTransitions ,
149
149
getNextLanes ,
150
- returnNextLanesPriority ,
151
150
markStarvedLanesAsExpired ,
152
151
getLanesToRetrySynchronouslyOnError ,
153
152
getMostRecentEventTime ,
@@ -156,12 +155,14 @@ import {
156
155
markRootPinged ,
157
156
markRootExpired ,
158
157
markRootFinished ,
159
- lanePriorityToSchedulerPriority ,
160
158
areLanesExpired ,
159
+ getHighestPriorityLane ,
161
160
} from './ReactFiberLane.new' ;
162
161
import {
163
162
DiscreteEventPriority ,
163
+ ContinuousEventPriority ,
164
164
DefaultEventPriority ,
165
+ IdleEventPriority ,
165
166
getCurrentUpdatePriority ,
166
167
setCurrentUpdatePriority ,
167
168
higherEventPriority ,
@@ -653,19 +654,20 @@ function ensureRootIsScheduled(root: FiberRoot, currentTime: number) {
653
654
root ,
654
655
root === workInProgressRoot ? workInProgressRootRenderLanes : NoLanes ,
655
656
) ;
656
- // This returns the priority level computed during the `getNextLanes` call.
657
- const newCallbackPriority = returnNextLanesPriority ( ) ;
658
657
659
658
if ( nextLanes === NoLanes ) {
660
659
// Special case: There's nothing to work on.
661
660
if ( existingCallbackNode !== null ) {
662
661
cancelCallback ( existingCallbackNode ) ;
663
662
}
664
663
root . callbackNode = null ;
665
- root . callbackPriority = NoLanePriority ;
664
+ root . callbackPriority = NoLane ;
666
665
return ;
667
666
}
668
667
668
+ // We use the highest priority lane to represent the priority of the callback.
669
+ const newCallbackPriority = getHighestPriorityLane ( nextLanes ) ;
670
+
669
671
// Check if there's an existing task. We may be able to reuse it.
670
672
const existingCallbackPriority = root . callbackPriority ;
671
673
if ( existingCallbackPriority === newCallbackPriority ) {
@@ -675,7 +677,7 @@ function ensureRootIsScheduled(root: FiberRoot, currentTime: number) {
675
677
// TODO: Temporary until we confirm this warning is not fired.
676
678
if (
677
679
existingCallbackNode == null &&
678
- existingCallbackPriority !== SyncLanePriority
680
+ existingCallbackPriority !== SyncLane
679
681
) {
680
682
console . error (
681
683
'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) {
693
695
694
696
// Schedule a new callback.
695
697
let newCallbackNode;
696
- if (newCallbackPriority === SyncLanePriority ) {
698
+ if (newCallbackPriority === SyncLane ) {
697
699
// Special case: Sync React callbacks are scheduled on a special
698
700
// internal queue
699
701
scheduleSyncCallback ( performSyncWorkOnRoot . bind ( null , root ) ) ;
@@ -706,9 +708,24 @@ function ensureRootIsScheduled(root: FiberRoot, currentTime: number) {
706
708
}
707
709
newCallbackNode = null;
708
710
} 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
+ }
712
729
newCallbackNode = scheduleCallback(
713
730
schedulerPriorityLevel,
714
731
performConcurrentWorkOnRoot.bind(null, root),
@@ -1744,7 +1761,7 @@ function commitRootImpl(root, renderPriorityLevel) {
1744
1761
// commitRoot never returns a continuation; it always finishes synchronously.
1745
1762
// So we can clear these now to allow a new callback to be scheduled.
1746
1763
root . callbackNode = null ;
1747
- root . callbackPriority = NoLanePriority ;
1764
+ root . callbackPriority = NoLane ;
1748
1765
1749
1766
// Update the first and last pending times on this root. The new first
1750
1767
// pending time is whatever is left on the root fiber.
0 commit comments