Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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!