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

Fix issue with useLocalStorage #109

Merged
merged 2 commits into from
Feb 21, 2022
Merged

Fix issue with useLocalStorage #109

merged 2 commits into from
Feb 21, 2022

Conversation

bogdanailincaipnt
Copy link
Contributor

@bogdanailincaipnt bogdanailincaipnt commented Feb 15, 2022

I was having an issue with useLocalStorage in my project, and this change is solving it.

The problem was that when I had 2 tabs opened, and I changed the localStorage value in one of the tabs, the other tab would not always update correctly.
I tried reproducing this bug in a codesandbox but wasn't able to. It's probably a very specific/complex scenario that has to happen. I am using SWR to fetch some data based on values from localStorage & other places, but there are also other details that would be too hard to reproduce in a codesandbox.

Even without managing to reproduce this issue separately, I think my proposed change is harmless and I hope it will be accepted, or maybe even improved. Perhaps you guys can better understand why my change would make a difference.
Also, after testing, I concluded that this is the commit that introduced the issue: bc3be93 .
Maybe other hooks have similar issues.

Thanks in advance!

I was having an issue with `useLocalStorage` in my project, and this change is solving it.

The problem was that when I had 2 tabs opened, and I changed the localStorage value in one of the tabs, the other tab would not always update correctly.
I tried reproducing this bug in a codesandbox but wasn't able to. It's probably a very specific/complex scenario that has to happen. I am using SWR (https://swr.vercel.app/) to fetch some data based on values from localStorage & other places, but there are also other details that would be too hard to reproduce in a codesandbox.

Even without managing to reproduce this issue separately, I think my proposed change is harmless and I hope it will be accepted, or maybe even improved. Perhaps you guys can better understand why my change would make a difference.
Also, after testing, I concluded that this is the commit that introduced the issue: bc3be93 .

Thanks in advance!
@juliencrn
Copy link
Owner

Hi @bogdanailincaipnt, thanks for the feedback and the fix.

It looks good, I will include it in the next release.

@juliencrn juliencrn merged commit 0c40d89 into juliencrn:master Feb 21, 2022
@bogdanailincaipnt bogdanailincaipnt deleted the patch-1 branch February 21, 2022 07:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants