usehooks
usehooks copied to clipboard
useDefault types
Hi, I used the useDefault
hook in my project with typescript in strict mode and had a little issue with the types returned by useDefault
.
If I write the following code
import { useDefault } from "@uidotdev/usehooks";
function getInitialFoo(): string | null {
return null;
}
export function App() {
const initalFoo = getInitialFoo();
const [foo, setFoo] = useDefault(initalFoo, "default");
}
then foo
is string | null
.
I would expect foo to be string
since the passed default value is a string
. So I was wondering if the types for useDefault
are correct? Or am I missing something?