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 0a92240 commit 5fecd80Copy full SHA for 5fecd80
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