(store: Store<State>, scope?: Scope)
| 27 | } |
| 28 | |
| 29 | export function useStoreBase<State>(store: Store<State>, scope?: Scope) { |
| 30 | useDeprecate(true, 'useStore', 'useUnit') |
| 31 | if (!is.store(store)) throwError('expect useStore argument to be a store') |
| 32 | |
| 33 | const subscribe = React.useCallback( |
| 34 | (fn: () => void) => createWatch({unit: store, fn, scope}), |
| 35 | [store, scope], |
| 36 | ) |
| 37 | const read = React.useCallback( |
| 38 | () => stateReader(store, scope), |
| 39 | [store, scope], |
| 40 | ) |
| 41 | const currentValue = useSyncExternalStore(subscribe, read, read) |
| 42 | |
| 43 | return currentValue |
| 44 | } |
| 45 | |
| 46 | export function useUnitBase<Shape extends {[key: string]: Unit<any>}>( |
| 47 | shape: Shape | {'@@unitShape': () => Shape}, |
no test coverage detected
searching dependent graphs…