Check for passive effects on the root fiber (#19488)
The root fiber doesn't have a parent from which we can read the `subtreeTag`, so we need to check its `effectTag` directly. The root fiber previously did not have any pending passive effects, but it does now that deleted fibers are cleaned up in the passive phase. This allows us to remove a `schedulePassiveEffectCallback` call from the synchronous unmount path. Co-authored-by: Brian Vaughn <bvaughn@fb.com>
Andrew Clark committed
Jul 30, 2020 at 08:17 UTC
6ef997b534bfbf10071401ea15b39a678d557135
2 files changed
+4
-3
packages/react-reconciler/src/ReactFiberCommitWork.new.js
-2
@@ -879,8 +879,6 @@ function commitUnmount(
879
if ((tag & HookPassive) !== NoHookEffect) {
880
// TODO: Consider if we can move this block out of the synchronous commit phase
881
effect.tag |= HookHasEffect;
882
-
883
- schedulePassiveEffectCallback();
882
} else {
883
if (
884
enableProfilerTimer &&
packages/react-reconciler/src/ReactFiberWorkLoop.new.js
+4
-1
@@ -2183,7 +2183,10 @@ function commitRootImpl(root, renderPriorityLevel) {
2183
}
2184
2185
// If there are pending passive effects, schedule a callback to process them.
2186
- if ((finishedWork.subtreeTag & PassiveSubtreeTag) !== NoSubtreeTag) {
2186
+ if (
2187
+ (finishedWork.subtreeTag & PassiveSubtreeTag) !== NoSubtreeTag ||
2188
+ (finishedWork.effectTag & PassiveMask) !== NoEffect
2189
+ ) {
2190
if (!rootDoesHavePassiveEffects) {
2191
rootDoesHavePassiveEffects = true;
2192
scheduleCallback(NormalSchedulerPriority, () => {