usehooks icon indicating copy to clipboard operation
usehooks copied to clipboard

useDarkMode TypeScript not working

Open mehrabmp opened this issue 2 years ago • 0 comments

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
  );

mehrabmp avatar May 14 '22 07:05 mehrabmp