DEV Community

Discussion on: Using the useReducer Hook in React with TypeScript

Collapse
 
lexlohr profile image
Alex Lohr

I believe useReducer is meant for cases where the transitions between the states (actions) are required to understand the underlying logic. In any other case, better use useState.

Collapse
 
swizzard profile image
sam

there's nothing useReducer can do that useState can't, and vice versa. the choice is just about clarity.

Collapse
 
lexlohr profile image
Alex Lohr

Exactly. And the choice should depend on whether the transitions are more meaningful to explain the task than the state itself.