(type: string)
| 17 | export type TransitionTypes = Array<string>; |
| 18 | |
| 19 | export function addTransitionType(type: string): void { |
| 20 | if (enableViewTransition) { |
| 21 | const transition = ReactSharedInternals.T; |
| 22 | if (transition !== null) { |
| 23 | const transitionTypes = transition.types; |
| 24 | if (transitionTypes === null) { |
| 25 | transition.types = [type]; |
| 26 | } else if (transitionTypes.indexOf(type) === -1) { |
| 27 | transitionTypes.push(type); |
| 28 | } |
| 29 | } else { |
| 30 | class="cm">// We're in the async gap. Simulate an implicit startTransition around it. |
| 31 | if (__DEV__) { |
| 32 | if (ReactSharedInternals.asyncTransitions === 0) { |
| 33 | if (enableGestureTransition) { |
| 34 | console.error( |
| 35 | class="st">'addTransitionType can only be called inside a `startTransition()` ' + |
| 36 | class="st">'or `startGestureTransition()` callback. ' + |
| 37 | class="st">'It must be associated with a specific Transition.', |
| 38 | ); |
| 39 | } else { |
| 40 | console.error( |
| 41 | class="st">'addTransitionType can only be called inside a `startTransition()` ' + |
| 42 | class="st">'callback. It must be associated with a specific Transition.', |
| 43 | ); |
| 44 | } |
| 45 | } |
| 46 | } |
| 47 | startTransition(addTransitionType.bind(null, type)); |
| 48 | } |
| 49 | } |
| 50 | } |
no test coverage detected