diff --git a/packages/react-reconciler/src/ReactFiberCommitWork.new.js b/packages/react-reconciler/src/ReactFiberCommitWork.new.js index 33ed1b5c95ce7..a86f580825f2f 100644 --- a/packages/react-reconciler/src/ReactFiberCommitWork.new.js +++ b/packages/react-reconciler/src/ReactFiberCommitWork.new.js @@ -1964,6 +1964,10 @@ function commitMutationEffects_begin( if (deletions !== null) { for (let i = 0; i < deletions.length; i++) { const childToDelete = deletions[i]; + // When deleting a host node, we follow the return path to find the + // neartest mounted host parent. Which means the return pointer of + // the deleted tree must be correct. + childToDelete.return = fiber; if (__DEV__) { invokeGuardedCallback( null, diff --git a/packages/react-reconciler/src/ReactFiberCommitWork.old.js b/packages/react-reconciler/src/ReactFiberCommitWork.old.js index 7574eb4fd3d3c..ff9cfb5f01c3b 100644 --- a/packages/react-reconciler/src/ReactFiberCommitWork.old.js +++ b/packages/react-reconciler/src/ReactFiberCommitWork.old.js @@ -1964,6 +1964,10 @@ function commitMutationEffects_begin( if (deletions !== null) { for (let i = 0; i < deletions.length; i++) { const childToDelete = deletions[i]; + // When deleting a host node, we follow the return path to find the + // neartest mounted host parent. Which means the return pointer of + // the deleted tree must be correct. + childToDelete.return = fiber; if (__DEV__) { invokeGuardedCallback( null,