144
import {
145
NoLanePriority,
146
SyncLanePriority,
147
+ SyncBatchedLanePriority,
148
InputDiscreteLanePriority,
149
TransitionShortLanePriority,
150
TransitionLongLanePriority,
727
newCallbackNode = scheduleSyncCallback(
728
performSyncWorkOnRoot.bind(null, root),
729
);
730
+ } else if (newCallbackPriority === SyncBatchedLanePriority) {
731
+ newCallbackNode = scheduleCallback(
732
+ ImmediateSchedulerPriority,
733
+ performSyncWorkOnRoot.bind(null, root),
734
+ );
735
} else {
736
const schedulerPriorityLevel = lanePriorityToSchedulerPriority(
737
newCallbackPriority,
762
763
// Flush any pending passive effects before deciding which lanes to work on,
764
// in case they schedule additional work.
759
- flushPassiveEffects();
765
+ const originalCallbackNode = root.callbackNode;
766
+ const didFlushPassiveEffects = flushPassiveEffects();
767
+ if (didFlushPassiveEffects) {
768
+ // Something in the passive effect phase may have canceled the current task.
769
+ // Check if the task node for this root was changed.
770
+ if (root.callbackNode !== originalCallbackNode) {
771
+ // The current task was canceled. Exit. We don't need to call
772
+ // `ensureRootIsScheduled` because the check above implies either that
773
+ // there's a new task, or that there's no remaining work on this root.
774
+ return null;
775
+ } else {
776
+ // Current task was not canceled. Continue.
777
+ }
778
+ }
779
780
// Determine the next expiration time to work on, using the fields stored
781
// on the root.
784
root === workInProgressRoot ? workInProgressRootRenderLanes : NoLanes,
785
);
786
if (lanes === NoLanes) {
787
+ // Defensive coding. This is never expected to happen.
788
return null;
789
}
790
801
return null;
802
}
803
784
- const originalCallbackNode = root.callbackNode;
785
-
804
let exitStatus = renderRootConcurrent(root, lanes);
805
806
if (
2611
resetCurrentDebugFiberInDEV();
2612
}
2613
2596
-export function flushPassiveEffects() {
2614
+export function flushPassiveEffects(): boolean {
2615
+ // Returns whether passive effects were flushed.
2616
if (pendingPassiveEffectsRenderPriority !== NoSchedulerPriority) {
2617
const priorityLevel =
2618
pendingPassiveEffectsRenderPriority > NormalSchedulerPriority
2629
setCurrentUpdateLanePriority(previousLanePriority);
2630
}
2631
}
2632
+ return false;
2633
}
2634
2635
export function enqueuePendingPassiveProfilerEffect(fiber: Fiber): void {