From 23595ff593b2e53ddfec2a08e848704d15d84b51 Mon Sep 17 00:00:00 2001 From: Brian Vaughn Date: Tue, 18 Aug 2020 12:02:04 -0400 Subject: [PATCH] Add missing param to safelyCallDestroy() (#19638) --- .../src/ReactFiberCommitWork.new.js | 27 +++++++++++++++---- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/packages/react-reconciler/src/ReactFiberCommitWork.new.js b/packages/react-reconciler/src/ReactFiberCommitWork.new.js index adc61e1aafd1c..063ff6fe49688 100644 --- a/packages/react-reconciler/src/ReactFiberCommitWork.new.js +++ b/packages/react-reconciler/src/ReactFiberCommitWork.new.js @@ -323,7 +323,11 @@ function commitBeforeMutationLifeCycles( ); } -function commitHookEffectListUnmount(tag: HookEffectTag, finishedWork: Fiber) { +function commitHookEffectListUnmount( + tag: HookEffectTag, + finishedWork: Fiber, + nearestMountedAncestor: Fiber | null, +) { const updateQueue: FunctionComponentUpdateQueue | null = (finishedWork.updateQueue: any); const lastEffect = updateQueue !== null ? updateQueue.lastEffect : null; if (lastEffect !== null) { @@ -335,7 +339,7 @@ function commitHookEffectListUnmount(tag: HookEffectTag, finishedWork: Fiber) { const destroy = effect.destroy; effect.destroy = undefined; if (destroy !== undefined) { - safelyCallDestroy(finishedWork, destroy); + safelyCallDestroy(finishedWork, nearestMountedAncestor, destroy); } } effect = effect.next; @@ -1598,12 +1602,17 @@ function commitWork(current: Fiber | null, finishedWork: Fiber): void { commitHookEffectListUnmount( HookLayout | HookHasEffect, finishedWork, + finishedWork.return, ); } finally { recordLayoutEffectDuration(finishedWork); } } else { - commitHookEffectListUnmount(HookLayout | HookHasEffect, finishedWork); + commitHookEffectListUnmount( + HookLayout | HookHasEffect, + finishedWork, + finishedWork.return, + ); } return; } @@ -1658,12 +1667,20 @@ function commitWork(current: Fiber | null, finishedWork: Fiber): void { ) { try { startLayoutEffectTimer(); - commitHookEffectListUnmount(HookLayout | HookHasEffect, finishedWork); + commitHookEffectListUnmount( + HookLayout | HookHasEffect, + finishedWork, + finishedWork.return, + ); } finally { recordLayoutEffectDuration(finishedWork); } } else { - commitHookEffectListUnmount(HookLayout | HookHasEffect, finishedWork); + commitHookEffectListUnmount( + HookLayout | HookHasEffect, + finishedWork, + finishedWork.return, + ); } return; }