AceDevHub
Intermediate React Interview QuestionsIntermediateComparison

React · Question 39

What is the difference between useState and useReducer, and when would you choose each?

Direct answer

useState is usually simpler for independent state values, while useReducer is useful when several related updates form a state transition model that is easier to express with actions.

ConcernuseStateuseReducer
Update APICall a setter with the next value/updaterDispatch an action
Best fitSimple or independent stateRelated state with multiple transition rules
Update logicOften lives near event handlersCentralized in a reducer
Debugging intentSetter shows value changeAction can describe what happened

A reducer does not make state global. useReducer() still manages state for the component instance unless you deliberately expose it through props or context.