Skip to content
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

useLocalStorageValue crashes when used via a data: URL #521

Closed
JoeDuncko opened this issue Dec 11, 2021 · 2 comments
Closed

useLocalStorageValue crashes when used via a data: URL #521

JoeDuncko opened this issue Dec 11, 2021 · 2 comments
Labels
🪲 bug Something isn't working released

Comments

@JoeDuncko
Copy link
Contributor

Prior Issues

Nope

What is the current behavior?

When you load a page via a data: url that uses useLocalStorageValue, the hook crashes with the current error:

Failed to read the 'localStorage' property from 'Window': Storage is disabled inside 'data:' URLs.

Steps to Reproduce

I'm not sure of the best way to reproduce this. My team hits the bug when we accidentally hit our frontend via Insomnia.

What is the expected behavior?

I really don't know. At least not crash, probably, but I don't know what results the hook should give, if any.

I'm mostly making this report in case anyone else hits this bug.

Environment Details

  • @react-hookz/web version: 12.0.0
  • react version: 17.0.2
  • react-dom version: 17.0.2
  • typescript version: n/a
  • OS: macOS 12.0.1
  • Browser: Insomnia 2021.7.2
  • Did this work in previous versions? Not sure
@JoeDuncko JoeDuncko added the 🪲 bug Something isn't working label Dec 11, 2021
@JoeDuncko JoeDuncko changed the title useLocalStorageValue crashed when used via a data: URL useLocalStorageValue crashes when used via a data: URL Dec 11, 2021
@xobotyi
Copy link
Contributor

xobotyi commented Dec 23, 2021

Guesss we have to fallback to undefined in case of inaccessibility of storages

github-actions bot pushed a commit that referenced this issue Jan 11, 2022
## [12.1.1](v12.1.0...v12.1.1) (2022-01-11)

### Bug Fixes

* **`useLocalStorage`, `useSessionStorage`:** replace hook with noop in case of storage absence. ([#540](#540)) ([790b302](790b302)), closes [#521](#521)
@xobotyi
Copy link
Contributor

xobotyi commented Jan 11, 2022

🎉 This issue has been resolved in version 12.1.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🪲 bug Something isn't working released
Development

No branches or pull requests

2 participants