FrontendDeveloper.in

React question detail

How is `useReducer` Different from `useState`?

There are notable differences between useState and useReducer hooks.

FeatureuseStateuseReducer
State complexitySimple (one variable or flat object)Complex, multi-part or deeply nested
Update styleDirect (e.g. setState(x))Through actions (e.g. dispatch({}))
Update logicIn componentIn reducer function
Reusability & testingLess reusableHighly reusable & testable
Back to all React questions
Get LinkedIn Premium at Rs 399