Skip to content

Commit 1b6e3dd

Browse files
authored
Merge restoreEnterViewTransitions and restoreExitViewTransitions (#32585)
This is the exact same code in both cases. It's just general clean up. By unifying them it becomes less confusing to reuse these helpers in the Apply Gesture path where the naming is reversed.
1 parent 5398b71 commit 1b6e3dd

File tree

2 files changed

+13
-31
lines changed

2 files changed

+13
-31
lines changed

packages/react-reconciler/src/ReactFiberCommitViewTransitions.js

Lines changed: 9 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -514,37 +514,20 @@ function restorePairedViewTransitions(parent: Fiber): void {
514514
}
515515
}
516516

517-
export function restoreEnterViewTransitions(placement: Fiber): void {
518-
if (placement.tag === ViewTransitionComponent) {
519-
const instance: ViewTransitionState = placement.stateNode;
520-
instance.paired = null;
521-
restoreViewTransitionOnHostInstances(placement.child, false);
522-
restorePairedViewTransitions(placement);
523-
} else if ((placement.subtreeFlags & ViewTransitionStatic) !== NoFlags) {
524-
let child = placement.child;
525-
while (child !== null) {
526-
restoreEnterViewTransitions(child);
527-
child = child.sibling;
528-
}
529-
} else {
530-
restorePairedViewTransitions(placement);
531-
}
532-
}
533-
534-
export function restoreExitViewTransitions(deletion: Fiber): void {
535-
if (deletion.tag === ViewTransitionComponent) {
536-
const instance: ViewTransitionState = deletion.stateNode;
517+
export function restoreEnterOrExitViewTransitions(fiber: Fiber): void {
518+
if (fiber.tag === ViewTransitionComponent) {
519+
const instance: ViewTransitionState = fiber.stateNode;
537520
instance.paired = null;
538-
restoreViewTransitionOnHostInstances(deletion.child, false);
539-
restorePairedViewTransitions(deletion);
540-
} else if ((deletion.subtreeFlags & ViewTransitionStatic) !== NoFlags) {
541-
let child = deletion.child;
521+
restoreViewTransitionOnHostInstances(fiber.child, false);
522+
restorePairedViewTransitions(fiber);
523+
} else if ((fiber.subtreeFlags & ViewTransitionStatic) !== NoFlags) {
524+
let child = fiber.child;
542525
while (child !== null) {
543-
restoreExitViewTransitions(child);
526+
restoreEnterOrExitViewTransitions(child);
544527
child = child.sibling;
545528
}
546529
} else {
547-
restorePairedViewTransitions(deletion);
530+
restorePairedViewTransitions(fiber);
548531
}
549532
}
550533

packages/react-reconciler/src/ReactFiberCommitWork.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,7 @@ import {
246246
commitExitViewTransitions,
247247
commitBeforeUpdateViewTransition,
248248
commitNestedViewTransitions,
249-
restoreEnterViewTransitions,
250-
restoreExitViewTransitions,
249+
restoreEnterOrExitViewTransitions,
251250
restoreUpdateViewTransition,
252251
restoreNestedViewTransitions,
253252
measureUpdateViewTransition,
@@ -3228,7 +3227,7 @@ function commitPassiveMountOnFiber(
32283227
// This was a new mount. This means we could've triggered an enter animation on
32293228
// the content. Restore the view transitions if there were any assigned in the
32303229
// snapshot phase.
3231-
restoreEnterViewTransitions(finishedWork);
3230+
restoreEnterOrExitViewTransitions(finishedWork);
32323231
}
32333232

32343233
// When updating this function, also update reconnectPassiveEffects, which does
@@ -3529,7 +3528,7 @@ function commitPassiveMountOnFiber(
35293528
// Content is now hidden but wasn't before. This means we could've
35303529
// triggered an exit animation on the content. Restore the view
35313530
// transitions if there were any assigned in the snapshot phase.
3532-
restoreExitViewTransitions(current);
3531+
restoreEnterOrExitViewTransitions(current);
35333532
}
35343533
if (instance._visibility & OffscreenPassiveEffectsConnected) {
35353534
// The effects are currently connected. Update them.
@@ -3576,7 +3575,7 @@ function commitPassiveMountOnFiber(
35763575
// Content is now visible but wasn't before. This means we could've
35773576
// triggered an enter animation on the content. Restore the view
35783577
// transitions if there were any assigned in the snapshot phase.
3579-
restoreEnterViewTransitions(finishedWork);
3578+
restoreEnterOrExitViewTransitions(finishedWork);
35803579
}
35813580
if (instance._visibility & OffscreenPassiveEffectsConnected) {
35823581
// The effects are currently connected. Update them.

0 commit comments

Comments
 (0)