Skip to content
37 changes: 37 additions & 0 deletions packages/react-reconciler/src/ReactFiberBeginWork.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ import {
DefaultHydrationLane,
SomeRetryLane,
includesSomeLane,
includesOnlyRetries,
laneToLanes,
removeLanes,
mergeLanes,
Expand Down Expand Up @@ -269,6 +270,7 @@ import {
scheduleUpdateOnFiber,
renderDidSuspendDelayIfPossible,
markSkippedUpdateLanes,
markRenderDerivedCause,
getWorkInProgressRoot,
peekDeferredLane,
} from './ReactFiberWorkLoop';
Expand Down Expand Up @@ -946,6 +948,13 @@ function updateDehydratedActivityComponent(
// but after we've already committed once.
warnIfHydrating();

if (includesSomeLane(renderLanes, (OffscreenLane: Lane))) {
// If we're rendering Offscreen and we're entering the activity then it's possible
// that the only reason we rendered was because this boundary left work. Provide
// it as a cause if another one doesn't already exist.
markRenderDerivedCause(workInProgress);
}

if (
// TODO: Factoring is a little weird, since we check this right below, too.
!didReceiveUpdate
Expand Down Expand Up @@ -1132,6 +1141,16 @@ function updateActivityComponent(
children: nextChildren,
};

if (
includesSomeLane(renderLanes, (OffscreenLane: Lane)) &&
includesSomeLane(renderLanes, current.lanes)
) {
// If we're rendering Offscreen and we're entering the activity then it's possible
// that the only reason we rendered was because this boundary left work. Provide
// it as a cause if another one doesn't already exist.
markRenderDerivedCause(workInProgress);
}

const primaryChildFragment = updateWorkInProgressOffscreenFiber(
currentChild,
offscreenChildProps,
Expand Down Expand Up @@ -2515,6 +2534,17 @@ function updateSuspenseComponent(
workInProgress.memoizedState = SUSPENDED_MARKER;
return fallbackChildFragment;
} else {
if (
prevState !== null &&
includesOnlyRetries(renderLanes) &&
includesSomeLane(renderLanes, current.lanes)
) {
// If we're rendering Retry lanes and we're entering the primary content then it's possible
// that the only reason we rendered was because we left this boundary to be warmed up but
// nothing else scheduled an update. If so, use it as the cause of the render.
markRenderDerivedCause(workInProgress);
}

pushPrimaryTreeSuspenseHandler(workInProgress);

const nextPrimaryChildren = nextProps.children;
Expand Down Expand Up @@ -2873,6 +2903,13 @@ function updateDehydratedSuspenseComponent(
// but after we've already committed once.
warnIfHydrating();

if (includesSomeLane(renderLanes, (OffscreenLane: Lane))) {
// If we're rendering Offscreen and we're entering the activity then it's possible
// that the only reason we rendered was because this boundary left work. Provide
// it as a cause if another one doesn't already exist.
markRenderDerivedCause(workInProgress);
}

if (isSuspenseInstanceFallback(suspenseInstance)) {
// This boundary is in a permanent fallback state. In this case, we'll never
// get an update and we'll never be able to hydrate the final content. Let's just try the
Expand Down
7 changes: 6 additions & 1 deletion packages/react-reconciler/src/ReactFiberHooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,10 @@ import {
markStateUpdateScheduled,
setIsStrictModeForDevtools,
} from './ReactFiberDevToolsHook';
import {startUpdateTimerByLane} from './ReactProfilerTimer';
import {
startUpdateTimerByLane,
startHostActionTimer,
} from './ReactProfilerTimer';
import {createCache} from './ReactFiberCacheComponent';
import {
createUpdate as createLegacyQueueUpdate,
Expand Down Expand Up @@ -3239,6 +3242,8 @@ export function startHostTransition<F>(
BasicStateAction<Thenable<TransitionStatus> | TransitionStatus>,
> = stateHook.queue;

startHostActionTimer(formFiber);

startTransition(
formFiber,
queue,
Expand Down
Loading
Loading