Skip to content
React·Intermediate·Coding·1 min read

Why should reducer actions describe events?

Short interview answer

Actions such as submitted or requestSucceeded record what happened, while vague setState actions leak implementation details. Event-shaped actions centralize invariants and make transitions readable, testable, and easier to evolve.

Example

JSX
// Leaky: caller decides the mechanicsdispatch({ type: 'setLoading', value: true });dispatch({ type: 'setError', value: null });
// Event-shaped: reducer owns the transitiondispatch({ type: 'submitted' });

Key takeaway

Explain the underlying mental model clearly, then support it with a concrete example and its trade-offs.

← Back to State modeling with reducers

Related questions