From c6947e4c2406288b8b7d770a7bd76c9de96cbecd Mon Sep 17 00:00:00 2001 From: Paul Shen Date: Sun, 17 Mar 2019 16:47:15 -0700 Subject: [PATCH 01/12] Clear nextEffect pointer for Deletion effects --- packages/react-reconciler/src/ReactFiberScheduler.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/react-reconciler/src/ReactFiberScheduler.js b/packages/react-reconciler/src/ReactFiberScheduler.js index e24e2ad71480..391815d7659a 100644 --- a/packages/react-reconciler/src/ReactFiberScheduler.js +++ b/packages/react-reconciler/src/ReactFiberScheduler.js @@ -521,7 +521,12 @@ function commitAllLifeCycles( rootWithPendingPassiveEffects = finishedRoot; } - nextEffect = nextEffect.nextEffect; + const nextNextEffect = nextEffect.nextEffect; + if (effectTag & Deletion) { + // Remove nextEffect reference to assist GC + nextEffect.nextEffect = null; + } + nextEffect = nextNextEffect; } if (__DEV__) { resetCurrentFiber(); From 7aa4b6cd314f79b487419c9e69554450bbedc120 Mon Sep 17 00:00:00 2001 From: Paul Shen Date: Sun, 17 Mar 2019 23:50:26 -0700 Subject: [PATCH 02/12] clear stateNode --- .../react-reconciler/src/ReactFiberCommitWork.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/packages/react-reconciler/src/ReactFiberCommitWork.js b/packages/react-reconciler/src/ReactFiberCommitWork.js index 544dccfd449a..52c1722d5aae 100644 --- a/packages/react-reconciler/src/ReactFiberCommitWork.js +++ b/packages/react-reconciler/src/ReactFiberCommitWork.js @@ -745,6 +745,8 @@ function commitUnmount(current: Fiber): void { return; } } + + current.stateNode = null; } function commitNestedUnmounts(root: Fiber): void { @@ -1041,19 +1043,15 @@ function unmountHostComponents(current): void { } if (node.tag === HostComponent || node.tag === HostText) { + // Save stateNode reference so commitUnmount can clear it. + const stateNode: Instance | TextInstance = node.stateNode; commitNestedUnmounts(node); // After all the children have unmounted, it is now safe to remove the // node from the tree. if (currentParentIsContainer) { - removeChildFromContainer( - ((currentParent: any): Container), - (node.stateNode: Instance | TextInstance), - ); + removeChildFromContainer(((currentParent: any): Container), stateNode); } else { - removeChild( - ((currentParent: any): Instance), - (node.stateNode: Instance | TextInstance), - ); + removeChild(((currentParent: any): Instance), stateNode); } // Don't visit children because we already visited them. } else if ( From 50de1fafc7f803cedd329846651e0fe2d58b1061 Mon Sep 17 00:00:00 2001 From: paulshen Date: Tue, 19 Mar 2019 15:58:57 -0700 Subject: [PATCH 03/12] remove stateNode from alternate as well --- packages/react-reconciler/src/ReactFiberCommitWork.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/react-reconciler/src/ReactFiberCommitWork.js b/packages/react-reconciler/src/ReactFiberCommitWork.js index 52c1722d5aae..166b32a5a136 100644 --- a/packages/react-reconciler/src/ReactFiberCommitWork.js +++ b/packages/react-reconciler/src/ReactFiberCommitWork.js @@ -747,6 +747,9 @@ function commitUnmount(current: Fiber): void { } current.stateNode = null; + if (current.alternate != null) { + current.alternate.stateNode = null; + } } function commitNestedUnmounts(root: Fiber): void { From c2bbc8d0a5a69444744dc0bc5b8bfe2aa1f87f88 Mon Sep 17 00:00:00 2001 From: paulshen Date: Tue, 19 Mar 2019 16:00:18 -0700 Subject: [PATCH 04/12] add comment --- packages/react-reconciler/src/ReactFiberCommitWork.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/react-reconciler/src/ReactFiberCommitWork.js b/packages/react-reconciler/src/ReactFiberCommitWork.js index 166b32a5a136..12e44606515c 100644 --- a/packages/react-reconciler/src/ReactFiberCommitWork.js +++ b/packages/react-reconciler/src/ReactFiberCommitWork.js @@ -746,6 +746,7 @@ function commitUnmount(current: Fiber): void { } } + // Remove reference for GC current.stateNode = null; if (current.alternate != null) { current.alternate.stateNode = null; From 21004823282fd2122a1954d8b10d571c5cbf08f3 Mon Sep 17 00:00:00 2001 From: Paul Shen Date: Tue, 19 Mar 2019 23:28:14 -0700 Subject: [PATCH 05/12] Unhook deletion effects from effect chain --- .../src/ReactFiberScheduler.js | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/packages/react-reconciler/src/ReactFiberScheduler.js b/packages/react-reconciler/src/ReactFiberScheduler.js index 391815d7659a..40cdb0df4f53 100644 --- a/packages/react-reconciler/src/ReactFiberScheduler.js +++ b/packages/react-reconciler/src/ReactFiberScheduler.js @@ -269,9 +269,11 @@ let nextRenderDidError: boolean = false; // The next fiber with an effect that we're currently committing. let nextEffect: Fiber | null = null; +// A previous fiber reference used to unlink the next effect. +let prevEffect: Fiber | null = null; let isCommitting: boolean = false; -let rootWithPendingPassiveEffects: FiberRoot | null = null; +let firstPassiveEffect: Fiber | null = null; let passiveEffectCallbackHandle: * = null; let passiveEffectCallback: * = null; @@ -517,15 +519,20 @@ function commitAllLifeCycles( commitAttachRef(nextEffect); } - if (effectTag & Passive) { - rootWithPendingPassiveEffects = finishedRoot; + if (effectTag & Passive && firstPassiveEffect === null) { + firstPassiveEffect = nextEffect; } const nextNextEffect = nextEffect.nextEffect; if (effectTag & Deletion) { - // Remove nextEffect reference to assist GC + // Remove node from effect chain for GC. We only do this with Deletion + // effects because we iterate the effect chain again for passive effects. nextEffect.nextEffect = null; + if (prevEffect !== null) { + prevEffect.nextEffect = nextNextEffect; + } } + prevEffect = nextEffect; nextEffect = nextNextEffect; } if (__DEV__) { @@ -534,7 +541,6 @@ function commitAllLifeCycles( } function commitPassiveEffects(root: FiberRoot, firstEffect: Fiber): void { - rootWithPendingPassiveEffects = null; passiveEffectCallbackHandle = null; passiveEffectCallback = null; @@ -765,6 +771,8 @@ function commitRoot(root: FiberRoot, finishedWork: Fiber): void { // and deletions in the entire tree have already been invoked. // This pass also triggers any renderer-specific initial effects. nextEffect = firstEffect; + prevEffect = null; + firstPassiveEffect = null; startCommitLifeCyclesTimer(); while (nextEffect !== null) { let didError = false; @@ -802,12 +810,12 @@ function commitRoot(root: FiberRoot, finishedWork: Fiber): void { } } - if (firstEffect !== null && rootWithPendingPassiveEffects !== null) { + if (firstPassiveEffect !== null) { // This commit included a passive effect. These do not need to fire until // after the next paint. Schedule an callback to fire them in an async // event. To ensure serial execution, the callback will be flushed early if - // we enter rootWithPendingPassiveEffects commit phase before then. - let callback = commitPassiveEffects.bind(null, root, firstEffect); + // we enter the commit phase before then. + let callback = commitPassiveEffects.bind(null, root, firstPassiveEffect); if (enableSchedulerTracing) { // TODO: Avoid this extra callback by mutating the tracing ref directly, // like we do at the beginning of commitRoot. I've opted not to do that From c1f16f363273ac32e1ff041bf438415423ffe826 Mon Sep 17 00:00:00 2001 From: Paul Shen Date: Wed, 20 Mar 2019 00:39:17 -0700 Subject: [PATCH 06/12] move to commitAllHostEffects and undo passive effect changes --- .../src/ReactFiberScheduler.js | 51 ++++++++++--------- 1 file changed, 28 insertions(+), 23 deletions(-) diff --git a/packages/react-reconciler/src/ReactFiberScheduler.js b/packages/react-reconciler/src/ReactFiberScheduler.js index 40cdb0df4f53..165ab062e00a 100644 --- a/packages/react-reconciler/src/ReactFiberScheduler.js +++ b/packages/react-reconciler/src/ReactFiberScheduler.js @@ -269,11 +269,12 @@ let nextRenderDidError: boolean = false; // The next fiber with an effect that we're currently committing. let nextEffect: Fiber | null = null; -// A previous fiber reference used to unlink the next effect. +// Fiber pointers used for effect chain manipulation. +let firstEffect: Fiber | null = null; let prevEffect: Fiber | null = null; let isCommitting: boolean = false; -let firstPassiveEffect: Fiber | null = null; +let rootWithPendingPassiveEffects: FiberRoot | null = null; let passiveEffectCallbackHandle: * = null; let passiveEffectCallback: * = null; @@ -423,6 +424,7 @@ function commitAllHostEffects() { // possible bitmap value, we remove the secondary effects from the // effect tag and switch on that value. let primaryEffectTag = effectTag & (Placement | Update | Deletion); + const nextNextEffect = nextEffect.nextEffect; switch (primaryEffectTag) { case Placement: { commitPlacement(nextEffect); @@ -453,10 +455,21 @@ function commitAllHostEffects() { } case Deletion: { commitDeletion(nextEffect); + + // We can now remove this Deletion node from the effect chain to assist GC. + if (prevEffect !== null) { + prevEffect.nextEffect = nextNextEffect; + } else { + firstEffect = nextNextEffect; + } + nextEffect.nextEffect = null; break; } } - nextEffect = nextEffect.nextEffect; + if (!(primaryEffectTag & Deletion)) { + prevEffect = nextEffect; + } + nextEffect = nextNextEffect; } if (__DEV__) { @@ -519,28 +532,22 @@ function commitAllLifeCycles( commitAttachRef(nextEffect); } - if (effectTag & Passive && firstPassiveEffect === null) { - firstPassiveEffect = nextEffect; + if (effectTag & Passive) { + rootWithPendingPassiveEffects = finishedRoot; } - const nextNextEffect = nextEffect.nextEffect; - if (effectTag & Deletion) { - // Remove node from effect chain for GC. We only do this with Deletion - // effects because we iterate the effect chain again for passive effects. - nextEffect.nextEffect = null; - if (prevEffect !== null) { - prevEffect.nextEffect = nextNextEffect; - } - } - prevEffect = nextEffect; - nextEffect = nextNextEffect; + nextEffect = nextEffect.nextEffect; } if (__DEV__) { resetCurrentFiber(); } } -function commitPassiveEffects(root: FiberRoot, firstEffect: Fiber): void { +function commitPassiveEffects( + root: FiberRoot, + firstNonDeletionEffect: Fiber, +): void { + rootWithPendingPassiveEffects = null; passiveEffectCallbackHandle = null; passiveEffectCallback = null; @@ -548,7 +555,7 @@ function commitPassiveEffects(root: FiberRoot, firstEffect: Fiber): void { const previousIsRendering = isRendering; isRendering = true; - let effect = firstEffect; + let effect = firstNonDeletionEffect; do { if (__DEV__) { setCurrentFiber(effect); @@ -661,7 +668,6 @@ function commitRoot(root: FiberRoot, finishedWork: Fiber): void { // Reset this to null before calling lifecycles ReactCurrentOwner.current = null; - let firstEffect; if (finishedWork.effectTag > PerformedWork) { // A fiber's effect list consists only of its children, not itself. So if // the root has an effect, we need to add it to the end of the list. The @@ -724,6 +730,7 @@ function commitRoot(root: FiberRoot, finishedWork: Fiber): void { // Commit all the side-effects within a tree. We'll do this in two passes. // The first pass performs all the host insertions, updates, deletions and // ref unmounts. + prevEffect = null; nextEffect = firstEffect; startCommitHostEffectsTimer(); while (nextEffect !== null) { @@ -771,8 +778,6 @@ function commitRoot(root: FiberRoot, finishedWork: Fiber): void { // and deletions in the entire tree have already been invoked. // This pass also triggers any renderer-specific initial effects. nextEffect = firstEffect; - prevEffect = null; - firstPassiveEffect = null; startCommitLifeCyclesTimer(); while (nextEffect !== null) { let didError = false; @@ -810,12 +815,12 @@ function commitRoot(root: FiberRoot, finishedWork: Fiber): void { } } - if (firstPassiveEffect !== null) { + if (rootWithPendingPassiveEffects !== null) { // This commit included a passive effect. These do not need to fire until // after the next paint. Schedule an callback to fire them in an async // event. To ensure serial execution, the callback will be flushed early if // we enter the commit phase before then. - let callback = commitPassiveEffects.bind(null, root, firstPassiveEffect); + let callback = commitPassiveEffects.bind(null, root, firstEffect); if (enableSchedulerTracing) { // TODO: Avoid this extra callback by mutating the tracing ref directly, // like we do at the beginning of commitRoot. I've opted not to do that From 80b908ccd0fa3074582cdd0fef27779f956a7a81 Mon Sep 17 00:00:00 2001 From: Paul Shen Date: Wed, 20 Mar 2019 00:43:40 -0700 Subject: [PATCH 07/12] fix flow --- packages/react-reconciler/src/ReactFiberScheduler.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/react-reconciler/src/ReactFiberScheduler.js b/packages/react-reconciler/src/ReactFiberScheduler.js index 165ab062e00a..f7e0e1a9c66b 100644 --- a/packages/react-reconciler/src/ReactFiberScheduler.js +++ b/packages/react-reconciler/src/ReactFiberScheduler.js @@ -730,7 +730,7 @@ function commitRoot(root: FiberRoot, finishedWork: Fiber): void { // Commit all the side-effects within a tree. We'll do this in two passes. // The first pass performs all the host insertions, updates, deletions and // ref unmounts. - prevEffect = null; + prevEffect = (null: Fiber | null); nextEffect = firstEffect; startCommitHostEffectsTimer(); while (nextEffect !== null) { @@ -816,10 +816,15 @@ function commitRoot(root: FiberRoot, finishedWork: Fiber): void { } if (rootWithPendingPassiveEffects !== null) { + invariant( + firstEffect !== null, + 'Should have next effect. This error is likely caused by a bug ' + + 'in React. Please file an issue.', + ); // This commit included a passive effect. These do not need to fire until // after the next paint. Schedule an callback to fire them in an async // event. To ensure serial execution, the callback will be flushed early if - // we enter the commit phase before then. + // we enter rootWithPendingPassiveEffects commit phase before then. let callback = commitPassiveEffects.bind(null, root, firstEffect); if (enableSchedulerTracing) { // TODO: Avoid this extra callback by mutating the tracing ref directly, From 41a983be0b0907b58a3dff7ddc2e4622df25f1e4 Mon Sep 17 00:00:00 2001 From: Paul Shen Date: Wed, 20 Mar 2019 00:45:24 -0700 Subject: [PATCH 08/12] cleanup --- packages/react-reconciler/src/ReactFiberScheduler.js | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/packages/react-reconciler/src/ReactFiberScheduler.js b/packages/react-reconciler/src/ReactFiberScheduler.js index f7e0e1a9c66b..f2491a7a7f6b 100644 --- a/packages/react-reconciler/src/ReactFiberScheduler.js +++ b/packages/react-reconciler/src/ReactFiberScheduler.js @@ -815,12 +815,7 @@ function commitRoot(root: FiberRoot, finishedWork: Fiber): void { } } - if (rootWithPendingPassiveEffects !== null) { - invariant( - firstEffect !== null, - 'Should have next effect. This error is likely caused by a bug ' + - 'in React. Please file an issue.', - ); + if (firstEffect !== null && rootWithPendingPassiveEffects !== null) { // This commit included a passive effect. These do not need to fire until // after the next paint. Schedule an callback to fire them in an async // event. To ensure serial execution, the callback will be flushed early if From de27cd4acb45b7655d21345dac14b0a2bd67cdfd Mon Sep 17 00:00:00 2001 From: paulshen Date: Mon, 8 Apr 2019 16:19:44 -0700 Subject: [PATCH 09/12] clear nextEffect chain --- .../react-reconciler/src/ReactFiberScheduler.new.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/react-reconciler/src/ReactFiberScheduler.new.js b/packages/react-reconciler/src/ReactFiberScheduler.new.js index c86bd58ce6a5..0959a4501a83 100644 --- a/packages/react-reconciler/src/ReactFiberScheduler.new.js +++ b/packages/react-reconciler/src/ReactFiberScheduler.new.js @@ -1404,6 +1404,12 @@ function commitRootImpl(root, expirationTime) { rootWithPendingPassiveEffects = root; pendingPassiveEffectsExpirationTime = expirationTime; } else { + nextEffect = firstEffect; + while (nextEffect !== null) { + const nextNextEffect = nextEffect.nextEffect; + nextEffect.nextEffect = null; + nextEffect = nextNextEffect; + } if (enableSchedulerTracing) { // If there are no passive effects, then we can complete the pending // interactions. Otherwise, we'll wait until after the passive effects @@ -1620,7 +1626,9 @@ export function flushPassiveEffects() { captureCommitPhaseError(effect, error); } } - effect = effect.nextEffect; + const nextNextEffect = effect.nextEffect; + effect.nextEffect = null; + effect = nextNextEffect; } if (enableSchedulerTracing) { From 2edaa1f3c1cc81920411f8ce927b7ba4b0270bff Mon Sep 17 00:00:00 2001 From: paulshen Date: Mon, 8 Apr 2019 16:29:20 -0700 Subject: [PATCH 10/12] remove all nextEffect pointers --- .../src/ReactFiberScheduler.new.js | 4 ++ .../src/ReactFiberScheduler.old.js | 41 ++++++++----------- 2 files changed, 22 insertions(+), 23 deletions(-) diff --git a/packages/react-reconciler/src/ReactFiberScheduler.new.js b/packages/react-reconciler/src/ReactFiberScheduler.new.js index 0959a4501a83..129ec2abaa0f 100644 --- a/packages/react-reconciler/src/ReactFiberScheduler.new.js +++ b/packages/react-reconciler/src/ReactFiberScheduler.new.js @@ -1404,6 +1404,9 @@ function commitRootImpl(root, expirationTime) { 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; @@ -1627,6 +1630,7 @@ export function flushPassiveEffects() { } } const nextNextEffect = effect.nextEffect; + // Remove nextEffect pointer to assist GC effect.nextEffect = null; effect = nextNextEffect; } diff --git a/packages/react-reconciler/src/ReactFiberScheduler.old.js b/packages/react-reconciler/src/ReactFiberScheduler.old.js index 2ea2e82ff967..5f10ca1708be 100644 --- a/packages/react-reconciler/src/ReactFiberScheduler.old.js +++ b/packages/react-reconciler/src/ReactFiberScheduler.old.js @@ -277,9 +277,6 @@ let nextRenderDidError: boolean = false; // The next fiber with an effect that we're currently committing. let nextEffect: Fiber | null = null; -// Fiber pointers used for effect chain manipulation. -let firstEffect: Fiber | null = null; -let prevEffect: Fiber | null = null; let isCommitting: boolean = false; let rootWithPendingPassiveEffects: FiberRoot | null = null; @@ -432,7 +429,6 @@ function commitAllHostEffects() { // possible bitmap value, we remove the secondary effects from the // effect tag and switch on that value. let primaryEffectTag = effectTag & (Placement | Update | Deletion); - const nextNextEffect = nextEffect.nextEffect; switch (primaryEffectTag) { case Placement: { commitPlacement(nextEffect); @@ -463,21 +459,10 @@ function commitAllHostEffects() { } case Deletion: { commitDeletion(nextEffect); - - // We can now remove this Deletion node from the effect chain to assist GC. - if (prevEffect !== null) { - prevEffect.nextEffect = nextNextEffect; - } else { - firstEffect = nextNextEffect; - } - nextEffect.nextEffect = null; break; } } - if (!(primaryEffectTag & Deletion)) { - prevEffect = nextEffect; - } - nextEffect = nextNextEffect; + nextEffect = nextEffect.nextEffect; } if (__DEV__) { @@ -551,10 +536,7 @@ function commitAllLifeCycles( } } -function commitPassiveEffects( - root: FiberRoot, - firstNonDeletionEffect: Fiber, -): void { +function commitPassiveEffects(root: FiberRoot, firstEffect: Fiber): void { rootWithPendingPassiveEffects = null; passiveEffectCallbackHandle = null; passiveEffectCallback = null; @@ -563,7 +545,7 @@ function commitPassiveEffects( const previousIsRendering = isRendering; isRendering = true; - let effect = firstNonDeletionEffect; + let effect = firstEffect; do { if (__DEV__) { setCurrentFiber(effect); @@ -592,7 +574,10 @@ function commitPassiveEffects( 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(); @@ -688,6 +673,7 @@ function commitRoot(root: FiberRoot, finishedWork: Fiber): void { // Reset this to null before calling lifecycles ReactCurrentOwner.current = null; + let firstEffect; if (finishedWork.effectTag > PerformedWork) { // A fiber's effect list consists only of its children, not itself. So if // the root has an effect, we need to add it to the end of the list. The @@ -750,7 +736,6 @@ function commitRoot(root: FiberRoot, finishedWork: Fiber): void { // Commit all the side-effects within a tree. We'll do this in two passes. // The first pass performs all the host insertions, updates, deletions and // ref unmounts. - prevEffect = (null: Fiber | null); nextEffect = firstEffect; startCommitHostEffectsTimer(); while (nextEffect !== null) { @@ -849,6 +834,16 @@ function commitRoot(root: FiberRoot, finishedWork: Fiber): void { } passiveEffectCallbackHandle = scheduleCallback(NormalPriority, 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 flushPassiveEffects. + nextEffect = firstEffect; + while (nextEffect !== null) { + const nextNextEffect = nextEffect.nextEffect; + nextEffect.nextEffect = null; + nextEffect = nextNextEffect; + } } isCommitting = false; From ea2c6d7132ee6d582d9e3ed661fb932b512d5889 Mon Sep 17 00:00:00 2001 From: paulshen Date: Mon, 8 Apr 2019 16:33:18 -0700 Subject: [PATCH 11/12] update comment --- packages/react-reconciler/src/ReactFiberScheduler.old.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-reconciler/src/ReactFiberScheduler.old.js b/packages/react-reconciler/src/ReactFiberScheduler.old.js index 5f10ca1708be..f1a6fa469136 100644 --- a/packages/react-reconciler/src/ReactFiberScheduler.old.js +++ b/packages/react-reconciler/src/ReactFiberScheduler.old.js @@ -837,7 +837,7 @@ function commitRoot(root: FiberRoot, finishedWork: Fiber): void { } 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. + // clear this in commitPassiveEffects. nextEffect = firstEffect; while (nextEffect !== null) { const nextNextEffect = nextEffect.nextEffect; From 568ef3e7ea530023397d4f01af31a1ee0aad2549 Mon Sep 17 00:00:00 2001 From: paulshen Date: Wed, 19 Jun 2019 11:37:47 -0700 Subject: [PATCH 12/12] break instead of return --- packages/react-reconciler/src/ReactFiberCommitWork.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/react-reconciler/src/ReactFiberCommitWork.js b/packages/react-reconciler/src/ReactFiberCommitWork.js index 218abb076ed0..d11c381c89c8 100644 --- a/packages/react-reconciler/src/ReactFiberCommitWork.js +++ b/packages/react-reconciler/src/ReactFiberCommitWork.js @@ -730,11 +730,11 @@ function commitUnmount(current: Fiber): void { if (typeof instance.componentWillUnmount === 'function') { safelyCallComponentWillUnmount(current, instance); } - return; + break; } case HostComponent: { safelyDetachRef(current); - return; + break; } case HostPortal: { // TODO: this is recursive. @@ -745,7 +745,7 @@ function commitUnmount(current: Fiber): void { } else if (supportsPersistence) { emptyPortalContainer(current); } - return; + break; } case EventComponent: { if (enableEventAPI) {