You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'd like to be able to read and modify multiple pieces of state from different contexts, such as tabs, and have any modifications to the store be persisted to storage and synced across all active contexts. I thought that was the purpose of this package, but it does not seem to work for the following setup:
When one tab calls incrementCount() the state of count2 is cleared from the local store. Thus on refresh of one or both tabs, the store is rehydrated and count2 is 0. Is this expected? Perhaps only one context is able to mutate the stores state?
If so are there any reasonable means of achieving the type of "complete synchronization" of state between tabs where each tab can execute actions upon the state and have the resulting state mutations also apply to the persisted store AND in-memory state of the other contexts using the shared store?
But by doing this we lose the ability to use more fine-grained selectors, and need to instead select the entire state during every read / update. Maybe this is unavoidable though? Any thoughts would be appreciated, and If I am misunderstanding how the package (or zustand in general) works, corrections are welcome. I am rather new to Zustand. Thanks.
Upvote & Fund
We're using Polar.sh so you can upvote and help fund this issue.
We receive the funding once the issue is completed & confirmed by you.
Thank you in advance for helping prioritize & fund our backlog.
The text was updated successfully, but these errors were encountered:
benripka
changed the title
Can only on tab / context mutate the state?
Can only one tab / context mutate the state?
Apr 28, 2024
benripka
changed the title
Can only one tab / context mutate the state?
Does this package only sync one state value from the store?
Apr 28, 2024
benripka
changed the title
Does this package only sync one state value from the store?
Does this package only persist one state value from the store?
Apr 28, 2024
I'd like to be able to read and modify multiple pieces of state from different contexts, such as tabs, and have any modifications to the store be persisted to storage and synced across all active contexts. I thought that was the purpose of this package, but it does not seem to work for the following setup:
When one tab calls
incrementCount()
the state of count2 is cleared from the local store. Thus on refresh of one or both tabs, the store is rehydrated and count2 is 0. Is this expected? Perhaps only one context is able to mutate the stores state?If so are there any reasonable means of achieving the type of "complete synchronization" of state between tabs where each tab can execute actions upon the state and have the resulting state mutations also apply to the persisted store AND in-memory state of the other contexts using the shared store?
I can make it work if I use something more like:
But by doing this we lose the ability to use more fine-grained selectors, and need to instead select the entire state during every read / update. Maybe this is unavoidable though? Any thoughts would be appreciated, and If I am misunderstanding how the package (or zustand in general) works, corrections are welcome. I am rather new to Zustand. Thanks.
Upvote & Fund
The text was updated successfully, but these errors were encountered: