@@ -2723,15 +2723,6 @@ function commitMutationEffectsOnFiber(
2723
2723
recursivelyTraverseDisappearLayoutEffects ( finishedWork ) ;
2724
2724
}
2725
2725
}
2726
- } else {
2727
- if ( wasHidden ) {
2728
- const isViewTransitionEligible =
2729
- enableViewTransition &&
2730
- includesOnlyViewTransitionEligibleLanes ( lanes ) ;
2731
- if ( isViewTransitionEligible ) {
2732
- commitEnterViewTransitions ( finishedWork ) ;
2733
- }
2734
- }
2735
2726
}
2736
2727
2737
2728
// Offscreen with manual mode manages visibility manually.
@@ -2855,16 +2846,6 @@ function commitReconciliationEffects(
2855
2846
// before the effects on this fiber have fired.
2856
2847
const flags = finishedWork . flags ;
2857
2848
if ( flags & Placement ) {
2858
- const isViewTransitionEligible =
2859
- enableViewTransition &&
2860
- includesOnlyViewTransitionEligibleLanes ( committedLanes ) ;
2861
- if ( isViewTransitionEligible ) {
2862
- // The first ViewTransition inside the Placement runs an enter transition
2863
- // but other nested ones don't.
2864
- // TODO: This shares the same traveral as commitHostPlacement below so it
2865
- // could be optimized to share the same pass.
2866
- commitEnterViewTransitions ( finishedWork ) ;
2867
- }
2868
2849
commitHostPlacement ( finishedWork ) ;
2869
2850
// Clear the "placement" from effect tag so that we know that this is
2870
2851
// inserted, before any life-cycles like componentDidMount gets called.
@@ -2937,6 +2918,19 @@ function commitAfterMutationEffectsOnFiber(
2937
2918
root : FiberRoot ,
2938
2919
lanes : Lanes ,
2939
2920
) {
2921
+ const current = finishedWork . alternate ;
2922
+ if ( current === null ) {
2923
+ // This is a newly inserted subtree. We can't use Placement flags to detect
2924
+ // this since they get removed in the mutation phase. Usually it's not enough
2925
+ // to just check current because that can also happen deeper in the same tree.
2926
+ // However, since we don't need to visit newly inserted subtrees in AfterMutation
2927
+ // we can just bail after we're done with the first one.
2928
+ // The first ViewTransition inside a newly mounted tree runs an enter transition
2929
+ // but other nested ones don't unless they have a named pair.
2930
+ commitEnterViewTransitions ( finishedWork ) ;
2931
+ return ;
2932
+ }
2933
+
2940
2934
switch ( finishedWork . tag ) {
2941
2935
case HostRoot : {
2942
2936
viewTransitionContextChanged = false ;
@@ -2967,7 +2961,6 @@ function commitAfterMutationEffectsOnFiber(
2967
2961
break ;
2968
2962
}
2969
2963
case OffscreenComponent : {
2970
- const current = finishedWork . alternate ;
2971
2964
const isModernRoot =
2972
2965
disableLegacyMode || ( finishedWork . mode & ConcurrentMode ) !== NoMode ;
2973
2966
if ( isModernRoot ) {
@@ -2976,8 +2969,9 @@ function commitAfterMutationEffectsOnFiber(
2976
2969
// The Offscreen tree is hidden. Skip over its after mutation effects.
2977
2970
} else {
2978
2971
// The Offscreen tree is visible.
2979
- const wasHidden = current !== null && current . memoizedState !== null ;
2972
+ const wasHidden = current . memoizedState !== null ;
2980
2973
if ( wasHidden ) {
2974
+ commitEnterViewTransitions ( finishedWork ) ;
2981
2975
// If it was previous hidden then the children are treated as enter
2982
2976
// not updates so we don't need to visit these children.
2983
2977
} else {
@@ -2990,11 +2984,7 @@ function commitAfterMutationEffectsOnFiber(
2990
2984
break ;
2991
2985
}
2992
2986
case ViewTransitionComponent : {
2993
- const current = finishedWork . alternate ;
2994
- if ( current === null ) {
2995
- // This is a new mount. We should have handled this as part of the
2996
- // Placement effect or it is deeper inside a entering transition.
2997
- } else if (
2987
+ if (
2998
2988
( finishedWork . subtreeFlags &
2999
2989
( Placement | Update | ChildDeletion | ContentReset | Visibility ) ) !==
3000
2990
NoFlags
0 commit comments