Skip to content

Commit ea1f986

Browse files
committed
Merge restoreEnterViewTransitions and restoreExitViewTransitions
1 parent ca8f91f commit ea1f986

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
@@ -241,8 +241,7 @@ import {
241241
commitExitViewTransitions,
242242
commitBeforeUpdateViewTransition,
243243
commitNestedViewTransitions,
244-
restoreEnterViewTransitions,
245-
restoreExitViewTransitions,
244+
restoreEnterOrExitViewTransitions,
246245
restoreUpdateViewTransition,
247246
restoreNestedViewTransitions,
248247
measureUpdateViewTransition,
@@ -3175,7 +3174,7 @@ function commitPassiveMountOnFiber(
31753174
// This was a new mount. This means we could've triggered an enter animation on
31763175
// the content. Restore the view transitions if there were any assigned in the
31773176
// snapshot phase.
3178-
restoreEnterViewTransitions(finishedWork);
3177+
restoreEnterOrExitViewTransitions(finishedWork);
31793178
}
31803179

31813180
// When updating this function, also update reconnectPassiveEffects, which does
@@ -3476,7 +3475,7 @@ function commitPassiveMountOnFiber(
34763475
// Content is now hidden but wasn't before. This means we could've
34773476
// triggered an exit animation on the content. Restore the view
34783477
// transitions if there were any assigned in the snapshot phase.
3479-
restoreExitViewTransitions(current);
3478+
restoreEnterOrExitViewTransitions(current);
34803479
}
34813480
if (instance._visibility & OffscreenPassiveEffectsConnected) {
34823481
// The effects are currently connected. Update them.
@@ -3523,7 +3522,7 @@ function commitPassiveMountOnFiber(
35233522
// Content is now visible but wasn't before. This means we could've
35243523
// triggered an enter animation on the content. Restore the view
35253524
// transitions if there were any assigned in the snapshot phase.
3526-
restoreEnterViewTransitions(finishedWork);
3525+
restoreEnterOrExitViewTransitions(finishedWork);
35273526
}
35283527
if (instance._visibility & OffscreenPassiveEffectsConnected) {
35293528
// The effects are currently connected. Update them.

0 commit comments

Comments
 (0)