You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When you set a local-storage item manually or by other means which is not using the hook, it throws an error.
I am using a custom script to store theme info which is just a string, so it does not need to be stringified. But when I am accessing the stored item using the hook it is sending undefined.
Local storage
theme : dark
Relevant log output
parsing error on {value: 'dark'}
Possible cause
This is probably happening because of the psrseJson function
function parseJSON<T>(value: string | null): T | undefined {
try {
return value === 'undefined' ? undefined : JSON.parse(value ?? '')
} catch {
console.log('parsing error on', { value })
return undefined
}
}
The text was updated successfully, but these errors were encountered:
Likely the easiest fix would be simply to have your custom script write a valid json value. something like: {"theme": "dark"}
however, if it is imperative that it not be json, check out #240
When you set a local-storage item manually or by other means which is not using the hook, it throws an error.
I am using a custom script to store
theme
info which is just a string, so it does not need to be stringified. But when I am accessing the stored item using the hook it is sendingundefined
.Local storage
theme
:dark
Relevant log output
Possible cause
This is probably happening because of the
psrseJson
functionThe text was updated successfully, but these errors were encountered: