From 5b19d05935a7bf7c5c5d2c9098c99a4665a30fc2 Mon Sep 17 00:00:00 2001 From: duqingyu <1065161421@qq.com> Date: Tue, 1 Nov 2022 18:54:05 +0800 Subject: [PATCH] fix(type): #10 fix Type checking error --- index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.ts b/index.ts index f822dd8..89deea1 100644 --- a/index.ts +++ b/index.ts @@ -13,7 +13,7 @@ type UseStateRef = { (): UseStateRefValue; }; -const useStateRef: UseStateRef = (initialState?: S | (() => S)): UseStateRefValue => { +const useStateRef: UseStateRef = (initialState?: S | (() => S)) => { const [state, setState] = useState(initialState); const ref = useRef(state); @@ -23,7 +23,7 @@ const useStateRef: UseStateRef = (initialState?: S | (() => S)): UseStateRefV setState(ref.current); }, []); - return [state, dispatch, ref]; + return [state, dispatch, ref] as UseStateRefValue; }; export = useStateRef;