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

Function useTransition

packages/react-debug-tools/src/ReactDebugHooks.js:484–505  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

482}
483
484function useTransition(): [
485 boolean,
486 (callback: () => void, options?: StartTransitionOptions) => void,
487] {
488 // useTransition() composes multiple hooks internally.
489 // Advance the current hook index the same number of times
490 // so that subsequent hooks have the right memoized state.
491 const stateHook = nextHook();
492 nextHook(); // Callback
493
494 const isPending = stateHook !== null ? stateHook.memoizedState : false;
495
496 hookLog.push({
497 displayName: null,
498 primitive: 'Transition',
499 stackError: new Error(),
500 value: isPending,
501 debugInfo: null,
502 dispatcherHookName: 'Transition',
503 });
504 return [isPending, () => {}];
505}
506
507function useDeferredValue<T>(value: T, initialValue?: T): T {
508 const hook = nextHook();

Callers 5

KeyValueFunction · 0.90
AppFunction · 0.50
FormFunction · 0.50

Calls 2

nextHookFunction · 0.85
pushMethod · 0.65

Tested by 2

AppFunction · 0.40
FormFunction · 0.40