Replies: 1 comment
-
To me, this feels beyond the scope of |
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
-
Recently I was adding
zustand
to a project that was previously persisting state manually. One of the requirements was not to lose data that was already persisted in the storage. The problem was thatpersist
expects the persisted state to have the following format:If it's different, i.ex. like this:
then
undefined
is returned. I found that it's not currently possible to handle that case without losing data that is already stored in the storage. To overcome this I created a patch that adds one more option to persist - a callback that is called whenstorageValue.state
is undefined. It allows users to define how to parse the already persisted value. Is that something that perhaps should be added tozustand
? If so, I can create a pull request with the necessary changes.Here's the diff with the changes I made: main...jmysliv:zustand:@jmysliv/get-state-fallback
Beta Was this translation helpful? Give feedback.
All reactions