What It Is
useReducer() is a method from the React Hooks API, similar to useState but gives you more control to manage the state. It tak...
For further actions, you may consider blocking this person and/or reporting abuse
For the first point you can still use State's hook functional form:
setState(state => state + 1)
.Explain
Why?
What you mean?
I have a screen where I show a list of (school) exams. When I click in one it navigates to another page where I can edit each exam field.
In this page I created a state for each single exam field (name, code, max weight, start date, end date, etc). Is this a case where I should've used a reducer? I also could create a state with the whole exam object right?
It's not clear to me the reducer advantage in my example.
the component for the second page or the second component should just accept the exam as a prop.
Very Nice, Thank You
not many benefits to reducer, I can still as easily test my state functions. by having the state handler be outside of the component.
Always coming back to this when I need a reminder. Very well written!
Very on point and well-written article. Thank you.
Nice piece. userReducer is always recommended when state is bigger and complex.
Cool explanation, Thanks for the short crisp & clear note.