Grokking React Advanced
Vote

0% completed

​

Working with Reducers in Redux

A function that takes the current state and an action, and returns the next state, is called a reducer. You wrote one for useReducer in React Fundamentals, and a Redux reducer has exactly the same shape. The difference is who calls it. With useReducer, React calls the reducer for one component; with Redux, the store calls it for the whole application every time an action is dispatched.

The to-do reducer

The previous lesson defined three actions: todos/addTodo, todos/toggleTodo and todos/removeTodo. The reducer below handles all three

.....

.....

.....

Like the course? Get enrolled and start learning!

Reading Progress

0%


Vote for new content