zustand concurrent update issue
zhaoyaoxin opened this issue · comments
lumos commented
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"