zustand concurrent update issue #2515
Unanswered
zhaoyaoxin
asked this question in
Bug report
Replies: 1 comment 4 replies
-
I guess you are facing a stale closure, but not sure. Can you create a reproduction?
|
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
zustand concurrent update issue
I'm having a problem when I'm modifying a state using zustand I call the update function twice in quick succession, but instead of initializing with the result of the first update the second update function uses the previous initial value causing the first update to be overwritten.
The original list is [1,2,3,4] The first update goes from [1,2,3,4] to [1,2,5,4] but the second update goes from [1,2,3,4] to [1,2,3,6] resulting in the final result of [1,2,3,6] The first update is overwritten.
"react": "^18.2.0"
"react-dom": "^18.2.0"
"zustand": "^4.3.8"
"immer": "^10.0.2"
Beta Was this translation helpful? Give feedback.
All reactions