@@ -677,10 +677,10 @@ function markUpdateLaneFromFiberToRoot(
677677}
678678
679679// Use this function to schedule a task for a root. There's only one task per
680- // root; if a task was already scheduled, we'll check to make sure the
681- // expiration time of the existing task is the same as the expiration time of
682- // the next level that the root has work on. This function is called on every
683- // update, and right before exiting a task.
680+ // root; if a task was already scheduled, we'll check to make sure the priority
681+ // of the existing task is the same as the priority of the next level that the
682+ // root has work on. This function is called on every update, and right before
683+ // exiting a task.
684684function ensureRootIsScheduled ( root : FiberRoot , currentTime : number ) {
685685 const existingCallbackNode = root . callbackNode ;
686686
@@ -689,37 +689,32 @@ function ensureRootIsScheduled(root: FiberRoot, currentTime: number) {
689689 markStarvedLanesAsExpired ( root , currentTime ) ;
690690
691691 // Determine the next lanes to work on, and their priority.
692- const newCallbackId = getNextLanes (
692+ const nextLanes = getNextLanes (
693693 root ,
694694 root === workInProgressRoot ? workInProgressRootRenderLanes : NoLanes ,
695695 ) ;
696696 // This returns the priority level computed during the `getNextLanes` call.
697697 const newCallbackPriority = returnNextLanesPriority ( ) ;
698698
699- if ( newCallbackId === NoLanes ) {
699+ if ( nextLanes === NoLanes ) {
700700 // Special case: There's nothing to work on.
701701 if ( existingCallbackNode !== null ) {
702702 cancelCallback ( existingCallbackNode ) ;
703703 root . callbackNode = null ;
704704 root . callbackPriority = NoLanePriority ;
705- root . callbackId = NoLanes ;
706705 }
707706 return ;
708707 }
709708
710709 // Check if there's an existing task. We may be able to reuse it.
711- const existingCallbackId = root . callbackId ;
712- const existingCallbackPriority = root . callbackPriority ;
713- if ( existingCallbackId !== NoLanes ) {
714- if ( newCallbackId === existingCallbackId ) {
715- // This task is already scheduled. Let's check its priority.
716- if ( existingCallbackPriority === newCallbackPriority ) {
717- // The priority hasn't changed. Exit.
718- return ;
719- }
720- // The task ID is the same but the priority changed. Cancel the existing
721- // callback. We'll schedule a new one below.
710+ if ( existingCallbackNode !== null ) {
711+ const existingCallbackPriority = root . callbackPriority ;
712+ if ( existingCallbackPriority === newCallbackPriority ) {
713+ // The priority hasn't changed. We can reuse the existing task. Exit.
714+ return;
722715 }
716+ // The priority changed. Cancel the existing callback. We'll schedule a new
717+ // one below.
723718 cancelCallback ( existingCallbackNode ) ;
724719 }
725720
@@ -741,7 +736,6 @@ function ensureRootIsScheduled(root: FiberRoot, currentTime: number) {
741736 ) ;
742737 }
743738
744- root.callbackId = newCallbackId;
745739 root.callbackPriority = newCallbackPriority;
746740 root.callbackNode = newCallbackNode;
747741}
@@ -2041,7 +2035,6 @@ function commitRootImpl(root, renderPriorityLevel) {
20412035 // commitRoot never returns a continuation; it always finishes synchronously.
20422036 // So we can clear these now to allow a new callback to be scheduled.
20432037 root . callbackNode = null ;
2044- root . callbackId = NoLanes ;
20452038
20462039 // Update the first and last pending times on this root. The new first
20472040 // pending time is whatever is left on the root fiber.
0 commit comments