| 460 | } |
| 461 | |
| 462 | function useSyncExternalStore<T>( |
| 463 | subscribe: (() => void) => () => void, |
| 464 | getSnapshot: () => T, |
| 465 | getServerSnapshot?: () => T, |
| 466 | ): T { |
| 467 | // useSyncExternalStore() composes multiple hooks internally. |
| 468 | // Advance the current hook index the same number of times |
| 469 | // so that subsequent hooks have the right memoized state. |
| 470 | nextHook(); // SyncExternalStore |
| 471 | nextHook(); // Effect |
| 472 | const value = getSnapshot(); |
| 473 | hookLog.push({ |
| 474 | displayName: null, |
| 475 | primitive: 'SyncExternalStore', |
| 476 | stackError: new Error(), |
| 477 | value, |
| 478 | debugInfo: null, |
| 479 | dispatcherHookName: 'SyncExternalStore', |
| 480 | }); |
| 481 | return value; |
| 482 | } |
| 483 | |
| 484 | function useTransition(): [ |
| 485 | boolean, |