I don't know if useReducer would help all that much TBH, but...
You know, the setState() function returned from useState() can be passed a function, to update the state, which receives the current state and you are expected to return the new state.
I feel useReducer() doesn't add all that much to state hooks, other than being familiar to redux users. I share some of the reasons for this point of view in this talk if you are interested: youtube.com/watch?v=gRXgE2iHRek
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Thanks. I'll look into it
I don't know if
useReducer
would help all that much TBH, but...You know, the
setState()
function returned fromuseState()
can be passed a function, to update the state, which receives the current state and you are expected to return the new state.This can be great when dealing with forms.
Here's that code a little expanded:
I feel
useReducer()
doesn't add all that much to state hooks, other than being familiar to redux users. I share some of the reasons for this point of view in this talk if you are interested:youtube.com/watch?v=gRXgE2iHRek