What is the motivation for a reducer?
What are actions in the context of a reducer? How are they different than setting state directly?
What common list operation is useReduce()
nameed for, and why?
useReduce()
is named for the reduce method. It is named this because it takes in a state and an action and returns a new state.When should you switch from useState()
to useReducer()
?
useState()
to useReducer()
when you have complex state logic that involves multiple sub-values or when the next state depends on the previous one. You should also switch when you have a lot of actions.What are your learning goals after reading and reviewing the class README?
useReducer()
.useReducer()
. Because as of right now, I am still confused about all of it.