-
Notifications
You must be signed in to change notification settings - Fork 18
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] State not syncing with React 17 #49
Comments
You need to put a unique key, otherwise they will be stored as the same key. |
Sorry that I didn't write the Expected behavior very clearly. I expected when I change the first component (hooked to localStorage), the second one should also sync. |
By the way I'm using https://usehooks-ts.com/react-hook/use-local-storage already. So if you are not maintaining it actively, I don't think we need to update this anymore. In this case, please consider close this issue. |
+1 on this issue. I was tempted to switch to My work around (inspired by use-hooks lib) looks like this:
I feel like this is a pretty easy fix on the lib though. In the mean time, you can also abstract this approach and use it for all of your |
What's the problem
When having multiple instance with same localStorage entry, only one of them will sync with localStorage.
Expected behavior
All instances will sync with localStorage as it is said in the documentation.
How to reproduce
Repeat the actions in the GIF with this sand box
https://codesandbox.io/s/react-storage-hooks-syincing-problem-7dgz5
ENV:
windows 1902
chrome 91
react 17
The text was updated successfully, but these errors were encountered: