diff --git a/src/useDefault.ts b/src/useDefault.ts index c552949b26..108ac52289 100644 --- a/src/useDefault.ts +++ b/src/useDefault.ts @@ -1,13 +1,13 @@ import { useState } from 'react'; -const useDefault = (defaultValue, initialValue): [any, (nextValue?: any) => void] => { - const [value, setValue] = useState(initialValue); +const useDefault = (defaultValue: TStateType, initialValue: TStateType | (() => TStateType)) => { + const [value, setValue] = useState(initialValue); if (value === undefined || value === null) { - return [defaultValue, setValue]; + return [defaultValue, setValue] as const; } - return [value, setValue]; + return [value, setValue] as const; }; export default useDefault;