In a large-scale app it would be simply to cumbersome to explicitly set useStatefor each of the state variables. So I would use useReducer in that case.
I'm a web developer with passion for my job. I love sharing my knowledge with fellow developers at my work and by writing articles about web development on personal blog
When there is too many state variables in a component, then it might be a sign that a component can be splitted into smaller ones. But it depends on a use case.
Both approaches have their use cases.
In a large-scale app it would be simply to cumbersome to explicitly set
useState
for each of the state variables. So I would useuseReducer
in that case.When there is too many state variables in a component, then it might be a sign that a component can be splitted into smaller ones. But it depends on a use case.
I agree with you. It might be the case, so it's good to have options and make informed trade-offs.