MCPcopy
hub / github.com/mobxjs/mobx / useLocalStore

Function useLocalStore

packages/mobx-react-lite/src/useLocalStore.ts:12–23  ·  view source on GitHub ↗
(
    initializer: (source?: TSource) => TStore,
    current?: TSource
)

Source from the content-addressed store, hash-verified

10 current: TSource
11): TStore
12export function useLocalStore<TStore extends Record<string, any>, TSource extends object>(
13 initializer: (source?: TSource) => TStore,
14 current?: TSource
15): TStore {
16 if ("production" !== process.env.NODE_ENV) {
17 useDeprecated(
18 "[mobx-react-lite] 'useLocalStore' is deprecated, use 'useLocalObservable' instead."
19 )
20 }
21 const source = current && useAsObservableSource(current)
22 return useState(() => observable(initializer(source), undefined, { autoBind: true }))[0]
23}

Callers 8

CounterFunction · 0.90
TestComponentFunction · 0.90
CounterFunction · 0.90
ChildFunction · 0.90
hooks.test.tsxFile · 0.90
TestComponentFunction · 0.90

Calls 3

useDeprecatedFunction · 0.90
useAsObservableSourceFunction · 0.90
observableFunction · 0.90

Tested by 5

CounterFunction · 0.72
TestComponentFunction · 0.72
CounterFunction · 0.72
ChildFunction · 0.72
TestComponentFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…