We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e93ac88 commit f07a764Copy full SHA for f07a764
packages/web/app/src/lib/hooks/use-local-storage-json.ts
@@ -31,11 +31,10 @@ export function useLocalStorageJson<$Schema extends z.ZodType>(...args: ArgsInpu
31
}
32
33
// todo: Some possible improvements:
34
- // - Monitor schema parse failures.
+ // - Monitor json/schema parse failures.
35
// - Let caller choose an error strategy: 'return' / 'default' / 'throw'
36
try {
37
- const parsed = JSON.parse(storedValue);
38
- return schema.parse(parsed);
+ return schema.parse(JSON.parse(storedValue));
39
} catch (_) {
40
return defaultValue;
41
0 commit comments