MCPcopy Create free account
hub / github.com/effector/effector / useStoreBase

Function useStoreBase

src/react/apiBase.ts:29–44  ·  view source on GitHub ↗
(store: Store<State>, scope?: Scope)

Source from the content-addressed store, hash-verified

27}
28
29export 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
46export function useUnitBase<Shape extends {[key: string]: Unit<any>}>(
47 shape: Shape | {'@@unitShape': () => Shape},

Callers 2

useStoreFunction · 0.90
useStoreFunction · 0.90

Calls 5

useDeprecateFunction · 0.90
throwErrorFunction · 0.90
createWatchFunction · 0.90
storeMethod · 0.80
stateReaderFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…