We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 92d8566 commit 71607dbCopy full SHA for 71607db
2 files changed
react/src/useCurrentAgent.ts
@@ -54,7 +54,7 @@ export const useCurrentAgent = (): [
54
export function initAgentFromLocalStorage(): Agent | undefined {
55
const lsItem = localStorage.getItem(AGENT_LOCAL_STORAGE_KEY);
56
57
- if (lsItem === null || lsItem === undefined) {
+ if (lsItem === null || lsItem === undefined || lsItem === 'undefined') {
58
return undefined;
59
}
60
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