usehooks
usehooks copied to clipboard
useDarkMode TypeScript not working
Hey, I was using the useDarkMode hook in typescript and I realized that it's not working probably cause you specify the type of boolean for local storage and the initial value of false and it's not working with nullish operator. I think you should add undefined to local storage type and use it as initial value.
const [enabledState, setEnabledState] = useLocalStorage<boolean | undefined>(
'dark-mode-enabled',
undefined
);