useDispatch: Creating and Deleting Tasks with Redux

Hands-on practice for this lecture. Write the code, see it run, understand the pattern.

1

Exercise 1 of 1

Implement useDispatch

useSelector is working. Wire the Add and Delete buttons with useDispatch — three steps, fully interactive task manager.

Task

useSelector is working — the initial task renders. Now wire the buttons using useDispatch.

  1. Call useDispatch() to get dispatch
  2. In addTask: dispatch ADD_TASK with { id: Date.now(), text: input }, then clear input
  3. In deleteTask: dispatch DELETE_TASK with the task id as payload
Loading editor…
Practice: useDispatch: Creating and Deleting Tasks with Redux — Interactive Exercises | Durgesh Rai