99
1010import type { Fiber } from './ReactInternalTypes' ;
1111import type { StackCursor } from './ReactFiberStack' ;
12- import type {
13- Container ,
14- HostContext ,
15- TransitionStatus ,
16- } from './ReactFiberConfig' ;
12+ import type { Container , HostContext } from './ReactFiberConfig' ;
1713import type { Hook } from './ReactFiberHooks' ;
18- import type { ReactContext } from 'shared/ReactTypes' ;
1914
2015import {
2116 getChildHostContext ,
2217 getRootHostContext ,
18+ HostTransitionContext ,
19+ NotPendingTransition ,
2320 isPrimaryRenderer ,
2421} from './ReactFiberConfig' ;
2522import { createCursor , push , pop } from './ReactFiberStack' ;
26- import { REACT_CONTEXT_TYPE } from 'shared/ReactSymbols' ;
2723import { enableAsyncActions } from 'shared/ReactFeatureFlags' ;
2824
2925const contextStackCursor : StackCursor < HostContext | null > = createCursor ( null ) ;
@@ -38,21 +34,6 @@ const rootInstanceStackCursor: StackCursor<Container | null> =
3834const hostTransitionProviderCursor : StackCursor < Fiber | null > =
3935 createCursor ( null ) ;
4036
41- // TODO: This should initialize to NotPendingTransition, a constant
42- // imported from the fiber config. However, because of a cycle in the module
43- // graph, that value isn't defined during this module's initialization. I can't
44- // think of a way to work around this without moving that value out of the
45- // fiber config. For now, the "no provider" case is handled when reading,
46- // inside useHostTransitionStatus.
47- export const HostTransitionContext : ReactContext < TransitionStatus | null > = {
48- $$typeof : REACT_CONTEXT_TYPE ,
49- Provider : ( null : any ) ,
50- Consumer : ( null : any ) ,
51- _currentValue : null ,
52- _currentValue2 : null ,
53- _threadCount : 0 ,
54- } ;
55-
5637function requiredContext < Value > (c: Value | null): Value {
5738 if ( __DEV__ ) {
5839 if ( c === null ) {
@@ -150,13 +131,13 @@ function popHostContext(fiber: Fiber): void {
150131 pop ( hostTransitionProviderCursor , fiber ) ;
151132
152133 // When popping the transition provider, we reset the context value back
153- // to `null `. We can do this because you're not allowd to nest forms. If
134+ // to `NotPendingTransition `. We can do this because you're not allowd to nest forms. If
154135 // we allowed for multiple nested host transition providers, then we'd
155136 // need to reset this to the parent provider's status.
156137 if ( isPrimaryRenderer ) {
157- HostTransitionContext . _currentValue = null ;
138+ HostTransitionContext . _currentValue = NotPendingTransition ;
158139 } else {
159- HostTransitionContext . _currentValue2 = null ;
140+ HostTransitionContext . _currentValue2 = NotPendingTransition ;
160141 }
161142 }
162143 }
0 commit comments