State Management · Junior · Question 74 of 75
What does a typical action object for useReducer look like?
dispatch({ type: "renamed", id: 3, title: "New title" });- ✓Correct answer: An object with a
typestring and any data the reducer needs - 2Only a string with the action name
- 3A function that returns the new state
Explanation
Any shape works, but a type field is the convention. With TypeScript, a discriminated union of action types gives exhaustive checking in the reducer.