Skip to content

Commit 55385a4

Browse files
committed
Pass SuspendedState to startViewTransition
That way we can transfer state from the collection of suspense commit info into the view transition start.
1 parent 94954ff commit 55385a4

File tree

4 files changed

+17
-1
lines changed

4 files changed

+17
-1
lines changed

packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2081,6 +2081,7 @@ function forceLayout(ownerDocument: Document) {
20812081
}
20822082

20832083
export function startViewTransition(
2084+
suspendedState: null | SuspendedState,
20842085
rootContainer: Container,
20852086
transitionTypes: null | TransitionTypes,
20862087
mutationCallback: () => void,
@@ -2443,6 +2444,7 @@ function animateGesture(
24432444
}
24442445

24452446
export function startGestureTransition(
2447+
suspendedState: null | SuspendedState,
24462448
rootContainer: Container,
24472449
timeline: GestureTimeline,
24482450
rangeStart: number,

packages/react-native-renderer/src/ReactFiberConfigNative.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -664,6 +664,7 @@ export function hasInstanceAffectedParent(
664664
}
665665

666666
export function startViewTransition(
667+
suspendedState: null | SuspendedState,
667668
rootContainer: Container,
668669
transitionTypes: null | TransitionTypes,
669670
mutationCallback: () => void,
@@ -684,6 +685,7 @@ export function startViewTransition(
684685
export type RunningViewTransition = null;
685686

686687
export function startGestureTransition(
688+
suspendedState: null | SuspendedState,
687689
rootContainer: Container,
688690
timeline: GestureTimeline,
689691
rangeStart: number,

packages/react-reconciler/src/ReactFiberWorkLoop.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import type {
2626
Resource,
2727
ViewTransitionInstance,
2828
RunningViewTransition,
29+
SuspendedState,
2930
} from './ReactFiberConfig';
3031
import type {RootState} from './ReactFiberRoot';
3132
import {
@@ -1379,6 +1380,7 @@ function finishConcurrentRender(
13791380
workInProgressRootInterleavedUpdatedLanes,
13801381
workInProgressSuspendedRetryLanes,
13811382
exitStatus,
1383+
null,
13821384
IMMEDIATE_COMMIT,
13831385
renderStartTime,
13841386
renderEndTime,
@@ -1487,10 +1489,11 @@ function commitRootWhenReady(
14871489
subtreeFlags & ShouldSuspendCommit ||
14881490
(subtreeFlags & BothVisibilityAndMaySuspendCommit) ===
14891491
BothVisibilityAndMaySuspendCommit;
1492+
let suspendedState: null | SuspendedState = null;
14901493
if (isViewTransitionEligible || maySuspendCommit || isGestureTransition) {
14911494
// Before committing, ask the renderer whether the host tree is ready.
14921495
// If it's not, we'll wait until it notifies us.
1493-
const suspendedState = startSuspendingCommit();
1496+
suspendedState = startSuspendingCommit();
14941497
// This will walk the completed fiber tree and attach listeners to all
14951498
// the suspensey resources. The renderer is responsible for accumulating
14961499
// all the load events. This all happens in a single synchronous
@@ -1541,6 +1544,7 @@ function commitRootWhenReady(
15411544
updatedLanes,
15421545
suspendedRetryLanes,
15431546
exitStatus,
1547+
suspendedState,
15441548
SUSPENDED_COMMIT,
15451549
completedRenderStartTime,
15461550
completedRenderEndTime,
@@ -1564,6 +1568,7 @@ function commitRootWhenReady(
15641568
updatedLanes,
15651569
suspendedRetryLanes,
15661570
exitStatus,
1571+
suspendedState,
15671572
suspendedCommitReason,
15681573
completedRenderStartTime,
15691574
completedRenderEndTime,
@@ -3287,6 +3292,7 @@ function commitRoot(
32873292
updatedLanes: Lanes,
32883293
suspendedRetryLanes: Lanes,
32893294
exitStatus: RootExitStatus,
3295+
suspendedState: null | SuspendedState,
32903296
suspendedCommitReason: SuspendedCommitReason, // Profiling-only
32913297
completedRenderStartTime: number, // Profiling-only
32923298
completedRenderEndTime: number, // Profiling-only
@@ -3438,6 +3444,7 @@ function commitRoot(
34383444
root,
34393445
finishedWork,
34403446
recoverableErrors,
3447+
suspendedState,
34413448
enableProfilerTimer
34423449
? suspendedCommitReason === IMMEDIATE_COMMIT
34433450
? completedRenderEndTime
@@ -3576,6 +3583,7 @@ function commitRoot(
35763583
pendingEffectsStatus = PENDING_MUTATION_PHASE;
35773584
if (enableViewTransition && willStartViewTransition) {
35783585
pendingViewTransition = startViewTransition(
3586+
suspendedState,
35793587
root.containerInfo,
35803588
pendingTransitionTypes,
35813589
flushMutationEffects,
@@ -3990,6 +3998,7 @@ function commitGestureOnRoot(
39903998
root: FiberRoot,
39913999
finishedWork: Fiber,
39924000
recoverableErrors: null | Array<CapturedValue<mixed>>,
4001+
suspendedState: null | SuspendedState,
39934002
renderEndTime: number, // Profiling-only
39944003
): void {
39954004
// We assume that the gesture we just rendered was the first one in the queue.
@@ -4020,6 +4029,7 @@ function commitGestureOnRoot(
40204029
pendingEffectsStatus = PENDING_GESTURE_MUTATION_PHASE;
40214030

40224031
pendingViewTransition = finishedGesture.running = startGestureTransition(
4032+
suspendedState,
40234033
root.containerInfo,
40244034
finishedGesture.provider,
40254035
finishedGesture.rangeStart,

packages/react-test-renderer/src/ReactFiberConfigTestHost.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,7 @@ export function hasInstanceAffectedParent(
414414
}
415415

416416
export function startViewTransition(
417+
suspendedState: null | SuspendedState,
417418
rootContainer: Container,
418419
transitionTypes: null | TransitionTypes,
419420
mutationCallback: () => void,
@@ -434,6 +435,7 @@ export function startViewTransition(
434435
export type RunningViewTransition = null;
435436

436437
export function startGestureTransition(
438+
suspendedState: null | SuspendedState,
437439
rootContainer: Container,
438440
timeline: GestureTimeline,
439441
rangeStart: number,

0 commit comments

Comments
 (0)