Calling state setter function in onRehydrateStorage listener is not working when onRehydrateStorage and partialize exists #1527
Labels
enhancement
New feature or request
help wanted
Please someone help on this
middleware/persist
This issue is about the persist middleware
Summary
When using persist middleware, if both
onRehydrateStorage
callback andpartialize
exist in the Persist options,Setting state by calling store function inside the onRehydrateStorage listener failed to set and update the state of the store
The demo demonstrates the problem,
even when the
setHasHydrated
andonRehydrateStorage
are being calledthe screen still stuck in loading because the store is value is not updated
this happens only in v4.3.X
v.4.2.0 has no such problem
Link to reproduction
https://codesandbox.io/s/zustand-4-3-x-bug-srmtzq?file=/src/App.js
Please download it and run it locally because CodePen Demo can't access localStorage directly
Check List
[ tick ] Please do not ask questions in issues.
Please fill this template if you're filling an issue regarding TypeScript.
create
is to be used ascreate<T>()(...)
and notcreate<T>(...)
.The text was updated successfully, but these errors were encountered: