diff --git a/lib/js/useMobxState.tsx b/lib/js/useMobxState.tsx index edbad0c..867dadf 100644 --- a/lib/js/useMobxState.tsx +++ b/lib/js/useMobxState.tsx @@ -1,4 +1,4 @@ -import { remove, runInAction, observable } from 'mobx'; +import { remove, runInAction, makeAutoObservable } from 'mobx'; import { useRef, useState } from 'react'; export function useMobxState>(state: T | (() => T)): T; @@ -6,7 +6,7 @@ export function useMobxState, P extends Record, P extends Record>(state: T | (() => T), props?: P): T & P { const initStateFunction = typeof state === "function" ? (state as any) : () => state; - const mobxState = useState(() => observable(initStateFunction(), undefined, { autoBind: true, proxy: false }))[0] as Record; + const mobxState = useState(() => makeAutoObservable(initStateFunction()))[0] as Record; const keyListOfState = useRef([]); diff --git a/package.json b/package.json index d5a33ef..f79abb4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mobx-react-use-autorun", - "version": "4.0.35", + "version": "4.0.36-beta", "description": "Provide concise usage for mobx in react", "scripts": { "test": "npx -y -p typescript -p ts-node ts-node --skipProject bin/mobx_react_test.ts",