Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions packages/react-reconciler/src/ReactFiberBeginWork.js
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,7 @@ function updateOffscreenComponent(
? mergeLanes(prevState.baseLanes, renderLanes)
: renderLanes;

let remainingChildLanes;
if (current !== null) {
// Reset to the current children
let currentChild = (workInProgress.child = current.child);
Expand All @@ -666,13 +667,12 @@ function updateOffscreenComponent(
currentChild = currentChild.sibling;
}
const lanesWeJustAttempted = nextBaseLanes;
const remainingChildLanes = removeLanes(
remainingChildLanes = removeLanes(
currentChildLanes,
lanesWeJustAttempted,
);
workInProgress.childLanes = remainingChildLanes;
} else {
workInProgress.childLanes = NoLanes;
remainingChildLanes = NoLanes;
workInProgress.child = null;
}

Expand All @@ -681,6 +681,7 @@ function updateOffscreenComponent(
workInProgress,
nextBaseLanes,
renderLanes,
remainingChildLanes,
);
}

Expand All @@ -707,8 +708,9 @@ function updateOffscreenComponent(
// and resume this tree later.

// Schedule this fiber to re-render at Offscreen priority
workInProgress.lanes = workInProgress.childLanes =
laneToLanes(OffscreenLane);

const remainingChildLanes = (workInProgress.lanes =
laneToLanes(OffscreenLane));

// Include the base lanes from the last render
const nextBaseLanes =
Expand All @@ -721,6 +723,7 @@ function updateOffscreenComponent(
workInProgress,
nextBaseLanes,
renderLanes,
remainingChildLanes,
);
} else {
// This is the second render. The surrounding visible content has already
Expand Down Expand Up @@ -826,6 +829,7 @@ function deferHiddenOffscreenComponent(
workInProgress: Fiber,
nextBaseLanes: Lanes,
renderLanes: Lanes,
remainingChildLanes: Lanes,
) {
const nextState: OffscreenState = {
baseLanes: nextBaseLanes,
Expand Down Expand Up @@ -856,6 +860,13 @@ function deferHiddenOffscreenComponent(
);
}

// We override the remaining child lanes to be the subset that we computed
// on the outside. We need to do this after propagating the context
// because propagateParentContextChangesToDeferredTree may schedule
// work which bubbles all the way up to the root and updates our child lanes.
// We want to dismiss that since we're not going to work on it yet.
workInProgress.childLanes = remainingChildLanes;

return null;
}

Expand Down
Loading