File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed
packages/react-reconciler/src Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -1712,6 +1712,16 @@ function commitRootImpl(root) {
17121712 rootDoesHavePassiveEffects = false ;
17131713 rootWithPendingPassiveEffects = root ;
17141714 pendingPassiveEffectsExpirationTime = expirationTime ;
1715+ } else {
1716+ // We are done with the effect chain at this point so let's clear the
1717+ // nextEffect pointers to assist with GC. If we have passive effects, we'll
1718+ // clear this in flushPassiveEffects.
1719+ nextEffect = firstEffect ;
1720+ while ( nextEffect !== null ) {
1721+ const nextNextEffect = nextEffect . nextEffect ;
1722+ nextEffect . nextEffect = null ;
1723+ nextEffect = nextNextEffect ;
1724+ }
17151725 }
17161726
17171727 // Check if there's remaining work on this root
@@ -1947,7 +1957,10 @@ export function flushPassiveEffects() {
19471957 captureCommitPhaseError ( effect , error ) ;
19481958 }
19491959 }
1950- effect = effect . nextEffect ;
1960+ const nextNextEffect = effect . nextEffect ;
1961+ // Remove nextEffect pointer to assist GC
1962+ effect . nextEffect = null ;
1963+ effect = nextNextEffect ;
19511964 }
19521965
19531966 if ( enableSchedulerTracing ) {
You can’t perform that action at this time.
0 commit comments