Reducers

Pascual Vila
Frontend Instructor.
Reducers are pure functions that take the current state and an action, and return a new state. They are the key piece in Redux for updating the application's state.
Example of a reducer:
{`function counter(state = 0, action) {
switch (action.type) {
case "INCREMENT":
return state + 1;
case "DECREMENT":
return state - 1;
default:
return state;
}
}`}