diff --git a/packages/react-reconciler/src/ReactFiberBeginWork.new.js b/packages/react-reconciler/src/ReactFiberBeginWork.new.js index cdbb5352eaa6b..fdd2398ebc955 100644 --- a/packages/react-reconciler/src/ReactFiberBeginWork.new.js +++ b/packages/react-reconciler/src/ReactFiberBeginWork.new.js @@ -2754,13 +2754,15 @@ 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); + // Guaranteed to be non-empty since the fiber is not a root. + const parentFiber: Fiber = (fiber.return: any); + scheduleContextWorkOnParentPath(parentFiber, renderLanes, parentFiber); } function propagateSuspenseContextChange( @@ -2776,7 +2778,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 +2786,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..1073ecd7d5f26 100644 --- a/packages/react-reconciler/src/ReactFiberBeginWork.old.js +++ b/packages/react-reconciler/src/ReactFiberBeginWork.old.js @@ -2754,13 +2754,15 @@ 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); + // Guaranteed to be non-empty since the fiber is not a root. + const parentFiber: Fiber = (fiber.return: any); + scheduleContextWorkOnParentPath(parentFiber, renderLanes, parentFiber); } function propagateSuspenseContextChange( @@ -2776,7 +2778,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 +2786,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/ReactFiberNewContext.new.js b/packages/react-reconciler/src/ReactFiberNewContext.new.js index 67eeac88a3cd6..996e463cd7480 100644 --- a/packages/react-reconciler/src/ReactFiberNewContext.new.js +++ b/packages/react-reconciler/src/ReactFiberNewContext.new.js @@ -141,7 +141,7 @@ export function popProvider( export function scheduleContextWorkOnParentPath( parent: Fiber | null, renderLanes: Lanes, - propagationRoot: Fiber | null, + propagationRoot: Fiber, ) { // Update the child lanes of all the ancestors, including the alternates. let node = parent; @@ -169,7 +169,7 @@ export function scheduleContextWorkOnParentPath( break; } if (__DEV__) { - if (propagationRoot !== null && node === propagationRoot.alternate) { + if (node === propagationRoot.alternate) { console.error( 'Did not expect to encounter a propagation root alternate when scheduling context work. ' + 'This error is likely caused by a bug in React. Please file an issue.', diff --git a/packages/react-reconciler/src/ReactFiberNewContext.old.js b/packages/react-reconciler/src/ReactFiberNewContext.old.js index aac18822c28bb..b8f6611d8d4af 100644 --- a/packages/react-reconciler/src/ReactFiberNewContext.old.js +++ b/packages/react-reconciler/src/ReactFiberNewContext.old.js @@ -141,7 +141,7 @@ export function popProvider( export function scheduleContextWorkOnParentPath( parent: Fiber | null, renderLanes: Lanes, - propagationRoot: Fiber | null, + propagationRoot: Fiber, ) { // Update the child lanes of all the ancestors, including the alternates. let node = parent; @@ -169,7 +169,7 @@ export function scheduleContextWorkOnParentPath( break; } if (__DEV__) { - if (propagationRoot !== null && node === propagationRoot.alternate) { + if (node === propagationRoot.alternate) { console.error( 'Did not expect to encounter a propagation root alternate when scheduling context work. ' + 'This error is likely caused by a bug in React. Please file an issue.',