| 482 | } |
| 483 | |
| 484 | function 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 | |
| 507 | function useDeferredValue<T>(value: T, initialValue?: T): T { |
| 508 | const hook = nextHook(); |