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" });

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.

Further reading

Problem with a question

State Management · Junior · question 74

Test yourself

Take the State Management · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz