-
Notifications
You must be signed in to change notification settings - Fork 32
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
Watch changes on storage and change state (closes #27) #30
Conversation
|
||
useEffect(() => { | ||
window.addEventListener('storage', handleStorage); | ||
return () => window.removeEventListener('storage', handleStorage); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If value
changes, causing handleStorage
callback to change, will removeEventListener
still work here then? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will remove and append again in the next cycle.
Thank you @VitorLuizC for the PR (turn off notifications w/ checking 😓) and @Svish for the review. |
Thank you again, @VitorLuizC. |
@all-contributors please add @Svish for review |
I've put up a pull request to add @Svish! 🎉 |
@dance2die Really not sure my question counts as a contribution, but up to you guys, hehe 😛 |
You were able to come up with the question because you read the code, spending your own time @Svish. And also the question was insightful, as I was wondering about it as well. |
I added a listener on storage that runs when modifying storage in another window or tab and an effect that runs on all cycles. Both change state if storage changes occur.
closes #27