We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 4281c7e commit 2c4953bCopy full SHA for 2c4953b
react/src/useLocalStorage.ts
@@ -17,6 +17,10 @@ export function useLocalStorage<T>(
17
// Get from local storage by key
18
const item = window.localStorage.getItem(key);
19
20
+ if (item === 'undefined') {
21
+ return initialValue;
22
+ }
23
+
24
// Parse stored json or if none return initialValue
25
return item ? JSON.parse(item) : initialValue;
26
} catch (error) {
0 commit comments