Skip to content

Commit

Permalink
Set return pointer of deleted tree
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
acdlite committed Mar 5, 2021
1 parent 80076d7 commit 01ece92
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/react-reconciler/src/ReactFiberCommitWork.new.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 4 additions & 0 deletions packages/react-reconciler/src/ReactFiberCommitWork.old.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 01ece92

Please sign in to comment.