Skip to content

Commit 2c4953b

Browse files
committed
Fix empty agent
1 parent 4281c7e commit 2c4953b

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

react/src/useLocalStorage.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ export function useLocalStorage<T>(
1717
// Get from local storage by key
1818
const item = window.localStorage.getItem(key);
1919

20+
if (item === 'undefined') {
21+
return initialValue;
22+
}
23+
2024
// Parse stored json or if none return initialValue
2125
return item ? JSON.parse(item) : initialValue;
2226
} catch (error) {

0 commit comments

Comments
 (0)