Skip to content

Commit 71607db

Browse files
committed
Fix empty agent
1 parent 92d8566 commit 71607db

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

react/src/useCurrentAgent.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export const useCurrentAgent = (): [
5454
export function initAgentFromLocalStorage(): Agent | undefined {
5555
const lsItem = localStorage.getItem(AGENT_LOCAL_STORAGE_KEY);
5656

57-
if (lsItem === null || lsItem === undefined) {
57+
if (lsItem === null || lsItem === undefined || lsItem === 'undefined') {
5858
return undefined;
5959
}
6060

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)