From 28d82de5d4963e95e999932b0661a071f10f4b4a Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Tue, 18 Jan 2022 19:05:50 +0000 Subject: [PATCH] Specify propagation root for Suspense too --- .../react-reconciler/src/ReactFiberBeginWork.new.js | 12 ++++++++---- .../react-reconciler/src/ReactFiberBeginWork.old.js | 12 ++++++++---- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/packages/react-reconciler/src/ReactFiberBeginWork.new.js b/packages/react-reconciler/src/ReactFiberBeginWork.new.js index cdbb5352eaa6b..dd35d7764057b 100644 --- a/packages/react-reconciler/src/ReactFiberBeginWork.new.js +++ b/packages/react-reconciler/src/ReactFiberBeginWork.new.js @@ -2754,13 +2754,17 @@ function updateDehydratedSuspenseComponent( } } -function scheduleContextWorkOnFiber(fiber: Fiber, renderLanes: Lanes) { +function scheduleSuspenseWorkOnFiber(fiber: Fiber, renderLanes: Lanes) { fiber.lanes = mergeLanes(fiber.lanes, renderLanes); const alternate = fiber.alternate; if (alternate !== null) { alternate.lanes = mergeLanes(alternate.lanes, renderLanes); } - scheduleContextWorkOnParentPath(fiber.return, renderLanes, null); + scheduleContextWorkOnParentPath( + fiber.return, + renderLanes, + fiber.return.return, + ); } function propagateSuspenseContextChange( @@ -2776,7 +2780,7 @@ function propagateSuspenseContextChange( if (node.tag === SuspenseComponent) { const state: SuspenseState | null = node.memoizedState; if (state !== null) { - scheduleContextWorkOnFiber(node, renderLanes); + scheduleSuspenseWorkOnFiber(node, renderLanes); } } else if (node.tag === SuspenseListComponent) { // If the tail is hidden there might not be an Suspense boundaries @@ -2784,7 +2788,7 @@ function propagateSuspenseContextChange( // list itself. // We don't have to traverse to the children of the list since // the list will propagate the change when it rerenders. - scheduleContextWorkOnFiber(node, renderLanes); + scheduleSuspenseWorkOnFiber(node, renderLanes); } else if (node.child !== null) { node.child.return = node; node = node.child; diff --git a/packages/react-reconciler/src/ReactFiberBeginWork.old.js b/packages/react-reconciler/src/ReactFiberBeginWork.old.js index 379245ebdfbc7..23ef764356ed5 100644 --- a/packages/react-reconciler/src/ReactFiberBeginWork.old.js +++ b/packages/react-reconciler/src/ReactFiberBeginWork.old.js @@ -2754,13 +2754,17 @@ function updateDehydratedSuspenseComponent( } } -function scheduleContextWorkOnFiber(fiber: Fiber, renderLanes: Lanes) { +function scheduleSuspenseWorkOnFiber(fiber: Fiber, renderLanes: Lanes) { fiber.lanes = mergeLanes(fiber.lanes, renderLanes); const alternate = fiber.alternate; if (alternate !== null) { alternate.lanes = mergeLanes(alternate.lanes, renderLanes); } - scheduleContextWorkOnParentPath(fiber.return, renderLanes, null); + scheduleContextWorkOnParentPath( + fiber.return, + renderLanes, + fiber.return.return, + ); } function propagateSuspenseContextChange( @@ -2776,7 +2780,7 @@ function propagateSuspenseContextChange( if (node.tag === SuspenseComponent) { const state: SuspenseState | null = node.memoizedState; if (state !== null) { - scheduleContextWorkOnFiber(node, renderLanes); + scheduleSuspenseWorkOnFiber(node, renderLanes); } } else if (node.tag === SuspenseListComponent) { // If the tail is hidden there might not be an Suspense boundaries @@ -2784,7 +2788,7 @@ function propagateSuspenseContextChange( // list itself. // We don't have to traverse to the children of the list since // the list will propagate the change when it rerenders. - scheduleContextWorkOnFiber(node, renderLanes); + scheduleSuspenseWorkOnFiber(node, renderLanes); } else if (node.child !== null) { node.child.return = node; node = node.child;