Skip to content

Commit

Permalink
clean up nextEffect pointers (#16115)
Browse files Browse the repository at this point in the history
  • Loading branch information
paulshen authored and sebmarkbage committed Jul 18, 2019
1 parent 997154b commit b4178af
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion packages/react-reconciler/src/ReactFiberWorkLoop.js
Expand Up @@ -1712,6 +1712,16 @@ function commitRootImpl(root) {
rootDoesHavePassiveEffects = false;
rootWithPendingPassiveEffects = root;
pendingPassiveEffectsExpirationTime = expirationTime;
} 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 flushPassiveEffects.
nextEffect = firstEffect;
while (nextEffect !== null) {
const nextNextEffect = nextEffect.nextEffect;
nextEffect.nextEffect = null;
nextEffect = nextNextEffect;
}
}

// Check if there's remaining work on this root
Expand Down Expand Up @@ -1947,7 +1957,10 @@ export function flushPassiveEffects() {
captureCommitPhaseError(effect, error);
}
}
effect = effect.nextEffect;
const nextNextEffect = effect.nextEffect;
// Remove nextEffect pointer to assist GC
effect.nextEffect = null;
effect = nextNextEffect;
}

if (enableSchedulerTracing) {
Expand Down

0 comments on commit b4178af

Please sign in to comment.