Function
useOptimistic
(
passthrough: S,
reducer: ?(S, A) => S,
)
Source from the content-addressed store, hash-verified
| 563 | } |
| 564 | |
| 565 | function useOptimistic<S, A>( |
| 566 | passthrough: S, |
| 567 | reducer: ?(S, A) => S, |
| 568 | ): [S, (A) => void] { |
| 569 | const hook = nextHook(); |
| 570 | let state; |
| 571 | if (hook !== null) { |
| 572 | state = hook.memoizedState; |
| 573 | } else { |
| 574 | state = passthrough; |
| 575 | } |
| 576 | hookLog.push({ |
| 577 | displayName: null, |
| 578 | primitive: 'Optimistic', |
| 579 | stackError: new Error(), |
| 580 | value: state, |
| 581 | debugInfo: null, |
| 582 | dispatcherHookName: 'Optimistic', |
| 583 | }); |
| 584 | return [state, (action: A) => {}]; |
| 585 | } |
| 586 | |
| 587 | function useFormState<S, P>( |
| 588 | action: (Awaited<S>, P) => S, |