astoilkov / use-local-storage-state

React hook that persists data in localStorage
MIT License
1.09k stars 39 forks source link

block all cookies in safari breaks the hook #62

Closed bobaaaaa closed 1 year ago

bobaaaaa commented 1 year ago

If you "block all cookies" in safari, this hook throws uncatched errors. It is not enough to surround the localStorage.getItem() call in a try-catch block. Even the localStorage access throws:

Bildschirmfoto 2023-05-10 um 13 56 24

This happened also for https://github.com/astoilkov/use-session-storage-state

Safari (16.4) settings promt. (sorry for the german language)

safari
astoilkov commented 1 year ago

I will fix this soon. Thanks!

astoilkov commented 1 year ago

This is now part of the latest release. Again, thanks for reporting!

I will migrate the change to use-session-storage-state as well soon.

bobaaaaa commented 1 year ago

Thank you. It works 👍. Will wait for use-session-storage-state because we are using both libs

bobaaaaa commented 1 year ago

@astoilkov should I create an issue on the https://github.com/astoilkov/use-session-storage-state repo?

astoilkov commented 1 year ago

Yeah, would probably be easier for you to keep track. Here I've done it: https://github.com/astoilkov/use-session-storage-state/issues/2.

Out of curiosity, where are you using both libraries?

bobaaaaa commented 1 year ago

Thanks 👍. My team is building t-online.de. It is one of the biggest german (online) news portals (300mio visits/month)

astoilkov commented 1 year ago

Wow. Is your organization open to sponsoring my work?

I'm not sure if you are familiar with the situation in open-source. It's the work of a lot of people that get little credit and money for the work they do. I think big organizations like yours are a way to improve that situation. This is a growing problem and the open-source community is trying to find a solution. This is why I'm experimenting with asking (inspiration: https://reactflow.dev/blog/asking-for-money-for-open-source/).

Thanks.

bobaaaaa commented 1 year ago

Sure. I will ask my boss.

astoilkov commented 1 year ago

Thank you!