Skip to content

Commit

Permalink
clear nextEffect
Browse files Browse the repository at this point in the history
  • Loading branch information
paulshen committed Jun 6, 2019
1 parent 487f4bf commit b0194a0
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion packages/react-reconciler/src/ReactFiberScheduler.js
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,10 @@ function commitPassiveEffects(root: FiberRoot, firstEffect: Fiber): void {
captureCommitPhaseError(effect, error);
}
}
effect = effect.nextEffect;
const nextNextEffect = effect.nextEffect;
// Remove nextEffect pointer to assist GC
effect.nextEffect = null;
effect = nextNextEffect;
} while (effect !== null);
if (__DEV__) {
resetCurrentFiber();
Expand Down Expand Up @@ -811,6 +814,16 @@ function commitRoot(root: FiberRoot, finishedWork: Fiber): void {
return schedulePassiveEffects(callback);
});
passiveEffectCallback = callback;
} else {
// We are done with the effect chain at this point so let's clear the
// nextEffect pointers to assist with GC. If we have passive effects, we'll
// clear this in commitPassiveEffects.
nextEffect = firstEffect;
while (nextEffect !== null) {
const nextNextEffect = nextEffect.nextEffect;
nextEffect.nextEffect = null;
nextEffect = nextNextEffect;
}
}

isCommitting = false;
Expand Down

0 comments on commit b0194a0

Please sign in to comment.