Skip to content

Commit

Permalink
fix(type): Aminadav#10 fix Type checking error
Browse files Browse the repository at this point in the history
  • Loading branch information
duqingyu committed Nov 1, 2022
1 parent 992be42 commit 5b19d05
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type UseStateRef = {
<S = undefined>(): UseStateRefValue<S>;
};

const useStateRef: UseStateRef = <S>(initialState?: S | (() => S)): UseStateRefValue<S> => {
const useStateRef: UseStateRef = <S>(initialState?: S | (() => S)) => {
const [state, setState] = useState(initialState);
const ref = useRef(state);

Expand All @@ -23,7 +23,7 @@ const useStateRef: UseStateRef = <S>(initialState?: S | (() => S)): UseStateRefV
setState(ref.current);
}, []);

return [state, dispatch, ref];
return [state, dispatch, ref] as UseStateRefValue<S>;
};

export = useStateRef;

0 comments on commit 5b19d05

Please sign in to comment.