diff --git a/src/hooks/useLocalStorage.js b/src/hooks/useLocalStorage.js index 21fec88..dbd6f0b 100644 --- a/src/hooks/useLocalStorage.js +++ b/src/hooks/useLocalStorage.js @@ -5,8 +5,8 @@ const getLocalValue = (key, initValue) => { if (typeof window === 'undefined') return initValue; // if a value is already store - const localValue = JSON.parse(localStorage.getItem(key)); - if (localValue) return localValue; + const localValue = localStorage.getItem(key); + if (localValue && localValue !== 'undefined') return JSON.parse(localValue); // return result of a function if (initValue instanceof Function) return initValue();