Skip to content

Commit

Permalink
Specify propagation root for Suspense too
Browse files Browse the repository at this point in the history
  • Loading branch information
gaearon committed Jan 18, 2022
1 parent 92c5c04 commit 28d82de
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
12 changes: 8 additions & 4 deletions packages/react-reconciler/src/ReactFiberBeginWork.new.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -2776,15 +2780,15 @@ 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
// to schedule work on. In this case we have to schedule it on the
// 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;
Expand Down
12 changes: 8 additions & 4 deletions packages/react-reconciler/src/ReactFiberBeginWork.old.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -2776,15 +2780,15 @@ 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
// to schedule work on. In this case we have to schedule it on the
// 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;
Expand Down

0 comments on commit 28d82de

Please sign in to comment.