Skip to content

Commit f07a764

Browse files
committed
tweak
1 parent e93ac88 commit f07a764

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

packages/web/app/src/lib/hooks/use-local-storage-json.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,10 @@ export function useLocalStorageJson<$Schema extends z.ZodType>(...args: ArgsInpu
3131
}
3232

3333
// todo: Some possible improvements:
34-
// - Monitor schema parse failures.
34+
// - Monitor json/schema parse failures.
3535
// - Let caller choose an error strategy: 'return' / 'default' / 'throw'
3636
try {
37-
const parsed = JSON.parse(storedValue);
38-
return schema.parse(parsed);
37+
return schema.parse(JSON.parse(storedValue));
3938
} catch (_) {
4039
return defaultValue;
4140
}

0 commit comments

Comments
 (0)