Skip to content

Commit 6ef997b

Browse files
acdliteBrian Vaughn
andauthored
Check for passive effects on the root fiber (facebook#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>
1 parent e1f96b8 commit 6ef997b

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

packages/react-reconciler/src/ReactFiberCommitWork.new.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -879,8 +879,6 @@ function commitUnmount(
879879
if ((tag & HookPassive) !== NoHookEffect) {
880880
// TODO: Consider if we can move this block out of the synchronous commit phase
881881
effect.tag |= HookHasEffect;
882-
883-
schedulePassiveEffectCallback();
884882
} else {
885883
if (
886884
enableProfilerTimer &&

packages/react-reconciler/src/ReactFiberWorkLoop.new.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2183,7 +2183,10 @@ function commitRootImpl(root, renderPriorityLevel) {
21832183
}
21842184

21852185
// 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+
) {
21872190
if (!rootDoesHavePassiveEffects) {
21882191
rootDoesHavePassiveEffects = true;
21892192
scheduleCallback(NormalSchedulerPriority, () => {

0 commit comments

Comments
 (0)