Replies: 1 comment
-
The issue was with React Natives Bottom Tab Navigator which did not rerender after zustood store got update post rehydration. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
I am having some trouble getting the persist middleware to work correctly.
Accortding to the docs, store options includes the
middleware
array andpersist
options in the same location andpersist.enabled
must be true to enable persistence. I addedname
as that is the only required parameter for persist.PeristOptions interface can be found here:
Zustand Persist docs:
https://github.com/pmndrs/zustand/blob/main/readme.md#persist-middleware
My code
Attempt 1
Atempt 2
I tried passing storeOptions as second parameter to createStore function as described in README.md under "Options"
Attempt 3
This is after inspecting the createStore function in Zustood source code:
https://github.com/udecode/zustood/blob/b6aad9310e2e54e0449542060cf72fb5335d5c1c/packages/zustood/src/createStore.ts#L33C7-L33C7
Zustood createStore code:
My Code
Error Message
Attempt 4
Removed middleware to match the example in issue #64
Error message
Attempt 6
Tried AsyncStorage, the error disappeared, however after restarting the app the previous state is not restored.
There is no error message other than the deprecation error regarding accessing passing vanilla stores (issue #60 )
Attempt 7
MIgrated to zustand and facing the same persist issue.
Tried different
storage
options like localStorage and AsyncStorage as well.Zustand error message:
How I am accessing the store
This is how I am using the store to interact with the state. All works great, just cant get the persist to work across app restarts
Beta Was this translation helpful? Give feedback.
All reactions