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

Function useLocalObservable

packages/mobx-react-lite/src/useLocalObservable.ts:4–9  ·  view source on GitHub ↗
(
    initializer: () => TStore,
    annotations?: AnnotationsMap<TStore, never>
)

Source from the content-addressed store, hash-verified

2import { useState } from "react"
3
4export function useLocalObservable<TStore extends Record<string, any>>(
5 initializer: () => TStore,
6 annotations?: AnnotationsMap<TStore, never>
7): TStore {
8 return useState(() => observable(initializer(), annotations, { autoBind: true }))[0]
9}

Callers 6

CounterFunction · 0.90
CounterFunction · 0.90
TestComponentFunction · 0.90

Calls 1

observableFunction · 0.90

Tested by 3

CounterFunction · 0.72
CounterFunction · 0.72
TestComponentFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…