-
-
Notifications
You must be signed in to change notification settings - Fork 426
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
useReadLocalStorage should not always parse value as JSON #240
Comments
Same problem for the useLocalStorage hook |
However, certainly, as this issue exists, there is a need for just interacting with the raw data. To me theres a couple of solutions on first glance that I think make sense:
|
Thanks all 🙌 #439 should fix most of the points here. Feel free to re-open the issue if needed |
See https://github.com/juliencrn/usehooks-ts/blob/master/src/useReadLocalStorage/useReadLocalStorage.ts#L18, there is an incorrect assumption where the localstorage value is always JSON, but this is not true, you can have a string.
Assume you have the following item in your localstorage
proposal
Treat localstorage values as type string, not JSON. Users can always do
Json.parse()
in the user land.The text was updated successfully, but these errors were encountered: