Skip to content

Commit

Permalink
fix: check for null
Browse files Browse the repository at this point in the history
  • Loading branch information
ayush987goyal committed Jan 16, 2020
1 parent 5316510 commit d619c39
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/useLocalStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const useLocalStorage = <T>(
const [state, setState] = useState<T>(() => {
try {
const localStorageValue = localStorage.getItem(key);
if (localStorageValue) {
if (localStorageValue !== null) {
return deserializer(localStorageValue);
} else {
initialValue && localStorage.setItem(key, serializer(initialValue));
Expand Down

0 comments on commit d619c39

Please sign in to comment.