From 41043779b2c4556ccb8ff5cfa902b11892d31403 Mon Sep 17 00:00:00 2001 From: Jack Cannon Date: Sun, 5 Mar 2023 16:10:21 +0000 Subject: [PATCH] Export types --- index.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/index.ts b/index.ts index e7a7b6c..c4c7209 100644 --- a/index.ts +++ b/index.ts @@ -3,16 +3,16 @@ import { useCallback, useRef, useState, SetStateAction, Dispatch } from "react"; const isFunction = (setStateAction: SetStateAction): setStateAction is (prevState: S) => S => typeof setStateAction === "function"; -type ReadOnlyRefObject = { +export type ReadOnlyRefObject = { readonly current: T; }; -type UseStateRef = { +export type UseStateRef = { (initialState: S | (() => S)): [S, Dispatch>, ReadOnlyRefObject]; (): [S | undefined, Dispatch>, ReadOnlyRefObject]; }; -const useStateRef: UseStateRef = (initialState?: S | (() => S)) => { +export const useStateRef: UseStateRef = (initialState?: S | (() => S)) => { const [state, setState] = useState(initialState); const ref = useRef(state); @@ -25,4 +25,4 @@ const useStateRef: UseStateRef = (initialState?: S | (() => S)) => { return [state, dispatch, ref]; }; -export = useStateRef; +export default useStateRef;