Skip to content

Commit 01ece92

Browse files
committed
Set return pointer of deleted tree
When deleting a host node, we follow the return path to find the nearest mounted host parent. Which means the return pointer of the deleted tree must be correct in the mutation phase.
1 parent 80076d7 commit 01ece92

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1964,6 +1964,10 @@ function commitMutationEffects_begin(
19641964
if (deletions !== null) {
19651965
for (let i = 0; i < deletions.length; i++) {
19661966
const childToDelete = deletions[i];
1967+
// When deleting a host node, we follow the return path to find the
1968+
// neartest mounted host parent. Which means the return pointer of
1969+
// the deleted tree must be correct.
1970+
childToDelete.return = fiber;
19671971
if (__DEV__) {
19681972
invokeGuardedCallback(
19691973
null,

packages/react-reconciler/src/ReactFiberCommitWork.old.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1964,6 +1964,10 @@ function commitMutationEffects_begin(
19641964
if (deletions !== null) {
19651965
for (let i = 0; i < deletions.length; i++) {
19661966
const childToDelete = deletions[i];
1967+
// When deleting a host node, we follow the return path to find the
1968+
// neartest mounted host parent. Which means the return pointer of
1969+
// the deleted tree must be correct.
1970+
childToDelete.return = fiber;
19671971
if (__DEV__) {
19681972
invokeGuardedCallback(
19691973
null,

0 commit comments

Comments
 (0)