What is useReducer and when to choose it over useState?
Answer
•useReducer is suitable for complex state.
•When there are many actions and transitions.
•Simplifies testing (reducer as a pure function).
•Works well with discriminated unions.
•Can be used for forms and complex UI.
Was this answer helpful?