Functional updates in Zustand? #2368
Unanswered
heymartinadams
asked this question in
General
Replies: 2 comments 6 replies
-
@heymartinadams would you mind sharing us a minimal code/demo on stackblitz? |
Beta Was this translation helpful? Give feedback.
0 replies
-
Pretty busy for this week, will do it if you still need me to. In the meantime, here’s how functional updates are used in React. If I try to do the same in Zustand, import * as React from 'react'
const [state, setState] = React.useState(0)
return (
<button onClick={() => setState(prev => prev + 1)}>
Click to increase
</button>
) |
Beta Was this translation helpful? Give feedback.
6 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Is this not possible in Zustand:
setMyCustomStateSetter(prev => ...)
?prev
doesn’t seem to be the previous state.Beta Was this translation helpful? Give feedback.
All reactions