Skip to content

Commit 7d93066

Browse files
committed
Specify propagation root for Suspense too
1 parent 92c5c04 commit 7d93066

File tree

4 files changed

+16
-12
lines changed

4 files changed

+16
-12
lines changed

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2754,13 +2754,15 @@ function updateDehydratedSuspenseComponent(
27542754
}
27552755
}
27562756

2757-
function scheduleContextWorkOnFiber(fiber: Fiber, renderLanes: Lanes) {
2757+
function scheduleSuspenseWorkOnFiber(fiber: Fiber, renderLanes: Lanes) {
27582758
fiber.lanes = mergeLanes(fiber.lanes, renderLanes);
27592759
const alternate = fiber.alternate;
27602760
if (alternate !== null) {
27612761
alternate.lanes = mergeLanes(alternate.lanes, renderLanes);
27622762
}
2763-
scheduleContextWorkOnParentPath(fiber.return, renderLanes, null);
2763+
// Guaranteed to be non-empty since the fiber is not a root.
2764+
const parentFiber: Fiber = (fiber.return: any);
2765+
scheduleContextWorkOnParentPath(parentFiber, renderLanes, parentFiber);
27642766
}
27652767

27662768
function propagateSuspenseContextChange(
@@ -2776,15 +2778,15 @@ function propagateSuspenseContextChange(
27762778
if (node.tag === SuspenseComponent) {
27772779
const state: SuspenseState | null = node.memoizedState;
27782780
if (state !== null) {
2779-
scheduleContextWorkOnFiber(node, renderLanes);
2781+
scheduleSuspenseWorkOnFiber(node, renderLanes);
27802782
}
27812783
} else if (node.tag === SuspenseListComponent) {
27822784
// If the tail is hidden there might not be an Suspense boundaries
27832785
// to schedule work on. In this case we have to schedule it on the
27842786
// list itself.
27852787
// We don't have to traverse to the children of the list since
27862788
// the list will propagate the change when it rerenders.
2787-
scheduleContextWorkOnFiber(node, renderLanes);
2789+
scheduleSuspenseWorkOnFiber(node, renderLanes);
27882790
} else if (node.child !== null) {
27892791
node.child.return = node;
27902792
node = node.child;

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2754,13 +2754,15 @@ function updateDehydratedSuspenseComponent(
27542754
}
27552755
}
27562756

2757-
function scheduleContextWorkOnFiber(fiber: Fiber, renderLanes: Lanes) {
2757+
function scheduleSuspenseWorkOnFiber(fiber: Fiber, renderLanes: Lanes) {
27582758
fiber.lanes = mergeLanes(fiber.lanes, renderLanes);
27592759
const alternate = fiber.alternate;
27602760
if (alternate !== null) {
27612761
alternate.lanes = mergeLanes(alternate.lanes, renderLanes);
27622762
}
2763-
scheduleContextWorkOnParentPath(fiber.return, renderLanes, null);
2763+
// Guaranteed to be non-empty since the fiber is not a root.
2764+
const parentFiber: Fiber = (fiber.return: any);
2765+
scheduleContextWorkOnParentPath(parentFiber, renderLanes, parentFiber);
27642766
}
27652767

27662768
function propagateSuspenseContextChange(
@@ -2776,15 +2778,15 @@ function propagateSuspenseContextChange(
27762778
if (node.tag === SuspenseComponent) {
27772779
const state: SuspenseState | null = node.memoizedState;
27782780
if (state !== null) {
2779-
scheduleContextWorkOnFiber(node, renderLanes);
2781+
scheduleSuspenseWorkOnFiber(node, renderLanes);
27802782
}
27812783
} else if (node.tag === SuspenseListComponent) {
27822784
// If the tail is hidden there might not be an Suspense boundaries
27832785
// to schedule work on. In this case we have to schedule it on the
27842786
// list itself.
27852787
// We don't have to traverse to the children of the list since
27862788
// the list will propagate the change when it rerenders.
2787-
scheduleContextWorkOnFiber(node, renderLanes);
2789+
scheduleSuspenseWorkOnFiber(node, renderLanes);
27882790
} else if (node.child !== null) {
27892791
node.child.return = node;
27902792
node = node.child;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ export function popProvider(
141141
export function scheduleContextWorkOnParentPath(
142142
parent: Fiber | null,
143143
renderLanes: Lanes,
144-
propagationRoot: Fiber | null,
144+
propagationRoot: Fiber,
145145
) {
146146
// Update the child lanes of all the ancestors, including the alternates.
147147
let node = parent;
@@ -169,7 +169,7 @@ export function scheduleContextWorkOnParentPath(
169169
break;
170170
}
171171
if (__DEV__) {
172-
if (propagationRoot !== null && node === propagationRoot.alternate) {
172+
if (node === propagationRoot.alternate) {
173173
console.error(
174174
'Did not expect to encounter a propagation root alternate when scheduling context work. ' +
175175
'This error is likely caused by a bug in React. Please file an issue.',

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ export function popProvider(
141141
export function scheduleContextWorkOnParentPath(
142142
parent: Fiber | null,
143143
renderLanes: Lanes,
144-
propagationRoot: Fiber | null,
144+
propagationRoot: Fiber,
145145
) {
146146
// Update the child lanes of all the ancestors, including the alternates.
147147
let node = parent;
@@ -169,7 +169,7 @@ export function scheduleContextWorkOnParentPath(
169169
break;
170170
}
171171
if (__DEV__) {
172-
if (propagationRoot !== null && node === propagationRoot.alternate) {
172+
if (node === propagationRoot.alternate) {
173173
console.error(
174174
'Did not expect to encounter a propagation root alternate when scheduling context work. ' +
175175
'This error is likely caused by a bug in React. Please file an issue.',

0 commit comments

Comments
 (0)