MCPcopy
hub / github.com/facebook/react / addTransitionType

Function addTransitionType

packages/react/src/ReactTransitionType.js:19–50  ·  packages/react/src/ReactTransitionType.js::addTransitionType
(type: string)

Source from the content-addressed store, hash-verified

17export type TransitionTypes = Array<string>;
18
19export 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}

Callers 5

toggleTabsFunction · 0.85
handleTabChangeFunction · 0.85
HeaderFunction · 0.85
ConfigEditorFunction · 0.85
handlerFunction · 0.85

Calls 3

startTransitionFunction · 0.90
pushMethod · 0.65
errorMethod · 0.65

Tested by

no test coverage detected