Skip to content

Commit 23595ff

Browse files
author
Brian Vaughn
authored
Add missing param to safelyCallDestroy() (#19638)
1 parent 24f1923 commit 23595ff

1 file changed

Lines changed: 22 additions & 5 deletions

File tree

‎packages/react-reconciler/src/ReactFiberCommitWork.new.js‎

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,11 @@ function commitBeforeMutationLifeCycles(
323323
);
324324
}
325325

326-
functioncommitHookEffectListUnmount(tag: HookEffectTag,finishedWork: Fiber){
326+
functioncommitHookEffectListUnmount(
327+
tag: HookEffectTag,
328+
finishedWork: Fiber,
329+
nearestMountedAncestor: Fiber|null,
330+
){
327331
constupdateQueue: FunctionComponentUpdateQueue|null=(finishedWork.updateQueue: any);
328332
constlastEffect=updateQueue!==null ? updateQueue.lastEffect : null;
329333
if(lastEffect!==null){
@@ -335,7 +339,7 @@ function commitHookEffectListUnmount(tag: HookEffectTag, finishedWork: Fiber) {
335339
constdestroy=effect.destroy;
336340
effect.destroy=undefined;
337341
if(destroy!==undefined){
338-
safelyCallDestroy(finishedWork,destroy);
342+
safelyCallDestroy(finishedWork,nearestMountedAncestor,destroy);
339343
}
340344
}
341345
effect=effect.next;
@@ -1598,12 +1602,17 @@ function commitWork(current: Fiber | null, finishedWork: Fiber): void {
15981602
commitHookEffectListUnmount(
15991603
HookLayout|HookHasEffect,
16001604
finishedWork,
1605+
finishedWork.return,
16011606
);
16021607
}finally{
16031608
recordLayoutEffectDuration(finishedWork);
16041609
}
16051610
}else{
1606-
commitHookEffectListUnmount(HookLayout|HookHasEffect,finishedWork);
1611+
commitHookEffectListUnmount(
1612+
HookLayout|HookHasEffect,
1613+
finishedWork,
1614+
finishedWork.return,
1615+
);
16071616
}
16081617
return;
16091618
}
@@ -1658,12 +1667,20 @@ function commitWork(current: Fiber | null, finishedWork: Fiber): void {
16581667
){
16591668
try{
16601669
startLayoutEffectTimer();
1661-
commitHookEffectListUnmount(HookLayout|HookHasEffect,finishedWork);
1670+
commitHookEffectListUnmount(
1671+
HookLayout|HookHasEffect,
1672+
finishedWork,
1673+
finishedWork.return,
1674+
);
16621675
}finally{
16631676
recordLayoutEffectDuration(finishedWork);
16641677
}
16651678
}else{
1666-
commitHookEffectListUnmount(HookLayout|HookHasEffect,finishedWork);
1679+
commitHookEffectListUnmount(
1680+
HookLayout|HookHasEffect,
1681+
finishedWork,
1682+
finishedWork.return,
1683+
);
16671684
}
16681685
return;
16691686
}

0 commit comments

Comments
 (0)