onRehydrateStorage is called before store.getItem #2584
Unanswered
jeffreyyoung
asked this question in
Bug report
Replies: 2 comments 2 replies
-
|
I wonder if anyone can help investigating it. |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
@jeffreyyoung would you mind creating the custom storage outside? |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Summary
These are the logs for the below store
Because onRehydrateStorage is called before storage.getItem, the store is always reset with default data.
For the following store:
Link to reproduction
https://codesandbox.io/p/sandbox/zustand-repro-pyys3x - see App.tsx and look at console logs
Beta Was this translation helpful? Give feedback.
All reactions