1 | import { observable, AnnotationsMap } from "mobx"
|
2 | import { useState } from "react"
|
3 |
|
4 | export 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 | }
|