You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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?
The text was updated successfully, but these errors were encountered:
Hi, I used the
useDefault
hook in my project with typescript in strict mode and had a little issue with the types returned byuseDefault
.If I write the following code
then
foo
isstring | null
.I would expect foo to be
string
since the passed default value is astring
. So I was wondering if the types foruseDefault
are correct? Or am I missing something?The text was updated successfully, but these errors were encountered: