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) {
1712
1712
rootDoesHavePassiveEffects = false ;
1713
1713
rootWithPendingPassiveEffects = root ;
1714
1714
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
+ }
1715
1725
}
1716
1726
1717
1727
// Check if there's remaining work on this root
@@ -1947,7 +1957,10 @@ export function flushPassiveEffects() {
1947
1957
captureCommitPhaseError ( effect , error ) ;
1948
1958
}
1949
1959
}
1950
- effect = effect . nextEffect ;
1960
+ const nextNextEffect = effect . nextEffect ;
1961
+ // Remove nextEffect pointer to assist GC
1962
+ effect . nextEffect = null ;
1963
+ effect = nextNextEffect ;
1951
1964
}
1952
1965
1953
1966
if ( enableSchedulerTracing ) {
You can’t perform that action at this time.
0 commit comments