Skip to content

Commit

Permalink
feat: Updated src/hooks/use-persisted-state.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
sweep-ai[bot] committed Feb 12, 2024
1 parent e70ba28 commit 458b897
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/hooks/use-persisted-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ export const usePersistedState = <T = unknown>(
) => {
const [value, setValue] = React.useState(() => {
const rawValue = window.localStorage.getItem(name);
return model.decode(rawValue);
if (rawValue === null) {
return model.decode(undefined);
}
return rawValue !== null ? model.decode(rawValue) : model.decode(undefined);
});

const isFirstRunRef = React.useRef(true);
Expand Down

0 comments on commit 458b897

Please sign in to comment.