Getting the previous state instead of the latest one when accessing the state in a different component #2148
Unanswered
fimbres
asked this question in
Bug report
Replies: 1 comment
-
@fimbres btw, I would do some improvements: setPlace: (place) => {
set({
workshop: {
...get().workshop,
place,
},
})
} // without immer
setPlace: (place) => {
set(state => ({
workshop: {
...state.workshop,
place
}
}))
} // with immer
setPlace: (place) => {
set(state => {
state.workshop.place = place
})
} |
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
-
I'm building a multi step form managing all the field using zustand, but in one step doesn't seem to be setting the state, I used zukeeper to debug the store and it seems to be working as expected, but then I console.log the value of the state at the end of the wizard to create a row in my database. but instead I don't get the version with all the fields in there, the last step values are missing somehow. And actually I'm setting the state in the same way for all the steps.
Store code:
Example on how I'm calling every action:
zukeeper output:
console.logging the state doesn't have the property place or meetingUrl defined, but zukeeper does.
This doesn't make any sense lol, I'm using version 4.4.1
Beta Was this translation helpful? Give feedback.
All reactions