-
Notifications
You must be signed in to change notification settings - Fork 22
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
Bug: Storage API always returns string on web #4
Comments
Hi, I made a fix for this in the the pull request #8 |
hey, I stumbled upon this bug today. Is there a path forward for merging the PR? Thanks for your time on this project. |
It's been over a year since a PR was proposed to address this but not a peep from maintainers. Also close to a year since any material changes were made to this repo, can we assume this is unmaintained? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, the following code always returns a
string
instead of anobject
after a page reload:I think it's caused by the following line https://github.com/ionic-team/ionic-react-hooks/blob/76745d1b3a0b4c62949dd6095ede3cbb4843c9ab/src/storage/useStorage.ts#L87 because on the web the type of
result.value
is alwaysstring
. Which is because of the implementation of the storage API for the web, wherelocalStorage.getItem()
always returns astring
ornull
for thevalue
key: https://github.com/ionic-team/capacitor/blob/f08e4a4f3cff1eedca3ca7292da7892ab2de5806/core/src/web/storage.ts#L21I fixed it for me the following way:
If you want I can submit a PR with the change, but I think there should be a better solution than using
try
andcatch
.The text was updated successfully, but these errors were encountered: