React question detail
How is `useReducer` Different from `useState`?
There are notable differences between useState and useReducer hooks.
| Feature | useState | useReducer |
|---|---|---|
| State complexity | Simple (one variable or flat object) | Complex, multi-part or deeply nested |
| Update style | Direct (e.g. setState(x)) | Through actions (e.g. dispatch({})) |
| Update logic | In component | In reducer function |
| Reusability & testing | Less reusable | Highly reusable & testable |