@@ -2161,7 +2161,15 @@ function runActionStateAction<S, P>(
2161
2161
const prevTransition = ReactSharedInternals . T ;
2162
2162
const currentTransition : Transition = ( { } : any ) ;
2163
2163
if ( enableViewTransition ) {
2164
- currentTransition . types = null ;
2164
+ currentTransition . types =
2165
+ prevTransition !== null
2166
+ ? // If we're a nested transition, we should use the same set as the parent
2167
+ // since we're conceptually always joined into the same entangled transition.
2168
+ // In practice, this only matters if we add transition types in the inner
2169
+ // without setting state. In that case, the inner transition can finish
2170
+ // without waiting for the outer.
2171
+ prevTransition . types
2172
+ : null ;
2165
2173
}
2166
2174
if ( enableGestureTransition ) {
2167
2175
currentTransition . gesture = null ;
@@ -2184,6 +2192,24 @@ function runActionStateAction<S, P>(
2184
2192
} catch ( error ) {
2185
2193
onActionError ( actionQueue , node , error ) ;
2186
2194
} finally {
2195
+ if ( prevTransition !== null && currentTransition . types !== null ) {
2196
+ // If we created a new types set in the inner transition, we transfer it to the parent
2197
+ // since they should share the same set. They're conceptually entangled.
2198
+ if ( __DEV__ ) {
2199
+ if (
2200
+ prevTransition . types !== null &&
2201
+ prevTransition . types !== currentTransition . types
2202
+ ) {
2203
+ // Just assert that assumption holds that we're not overriding anything.
2204
+ console . error (
2205
+ 'We expected inner Transitions to have transferred the outer types set and ' +
2206
+ 'that you cannot add to the outer Transition while inside the inner.' +
2207
+ 'This is a bug in React.' ,
2208
+ ) ;
2209
+ }
2210
+ }
2211
+ prevTransition . types = currentTransition . types ;
2212
+ }
2187
2213
ReactSharedInternals . T = prevTransition ;
2188
2214
2189
2215
if ( __DEV__ ) {
@@ -3057,7 +3083,15 @@ function startTransition<S>(
3057
3083
const prevTransition = ReactSharedInternals . T ;
3058
3084
const currentTransition : Transition = ( { } : any ) ;
3059
3085
if ( enableViewTransition ) {
3060
- currentTransition . types = null ;
3086
+ currentTransition . types =
3087
+ prevTransition !== null
3088
+ ? // If we're a nested transition, we should use the same set as the parent
3089
+ // since we're conceptually always joined into the same entangled transition.
3090
+ // In practice, this only matters if we add transition types in the inner
3091
+ // without setting state. In that case, the inner transition can finish
3092
+ // without waiting for the outer.
3093
+ prevTransition . types
3094
+ : null ;
3061
3095
}
3062
3096
if ( enableGestureTransition ) {
3063
3097
currentTransition . gesture = null ;
@@ -3144,6 +3178,24 @@ function startTransition<S>(
3144
3178
} finally {
3145
3179
setCurrentUpdatePriority ( previousPriority ) ;
3146
3180
3181
+ if ( prevTransition !== null && currentTransition . types !== null ) {
3182
+ // If we created a new types set in the inner transition, we transfer it to the parent
3183
+ // since they should share the same set. They're conceptually entangled.
3184
+ if ( __DEV__ ) {
3185
+ if (
3186
+ prevTransition . types !== null &&
3187
+ prevTransition . types !== currentTransition . types
3188
+ ) {
3189
+ // Just assert that assumption holds that we're not overriding anything.
3190
+ console . error (
3191
+ 'We expected inner Transitions to have transferred the outer types set and ' +
3192
+ 'that you cannot add to the outer Transition while inside the inner.' +
3193
+ 'This is a bug in React.' ,
3194
+ ) ;
3195
+ }
3196
+ }
3197
+ prevTransition.types = currentTransition.types;
3198
+ }
3147
3199
ReactSharedInternals . T = prevTransition ;
3148
3200
3149
3201
if ( __DEV__ ) {
0 commit comments