-
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
Could you provide a "sharedSessionStorage" storage object? #13
Comments
I just tried this package (https://www.npmjs.com/package/shared-session-storage) but I get the same issue, could it be a bug in this hook implementation? (in the Chrome Dev Tools I see the correct values) |
Hi @FezVrasta! The library does synchronize data between tabs... Did you actually try it and didn't work? Then it'd be a bug. Please let me know. Thanks! |
Yes I tried but the components don’t seem to receive the updated values |
If you can provide a minimal reproducible example, I can try looking into it. Thanks again! |
You can try this one https://codesandbox.io/s/friendly-satoshi-dg2p2?file=/src/App.js Open the app in two different tabs, click the "Random" button, observe the values are not in sync between the two tabs, but if you look into the Chrome Dev Tools, in the Session Storage you see the |
Okay, it does work if I change it to |
According to MDN docs: https://developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage
This is working as it should, only |
Of course, but the broadcast channel syncs it across tabs. |
This worries me since it seems (from this issue, couldn't find anything in repo) that we're sharing
Does this lib do anything related to this? I expect it to work just fine with |
The point of my request is to have some shared state across tabs, that is not persisted after the tabs are closed. Also, looking at my demo you can see everything in the synchronization logic works, it's just not reflected to React. |
If this lib is ever maintained again it would be a nice optional behavior, just don't make it the default behavior. Given all the unmerged PRs, my guess is this lib is abandoned. Bummer. |
Could this library provide a "sharedSessionStorage" that would work just like "sessionStorage", but with synchronization between different tabs?
It could use BroadcastChannel to keep them in sync.
I think it should look like this:
But it doesn't seem to notify the
useStorageState
hooks when a new value is set from a BroadcastChannel message.The text was updated successfully, but these errors were encountered: