State Management · Junior · Question 52 of 75
When should two pieces of state be combined into one object?
- ✓Correct answer: When they always change together (e.g.
xandyof a pointer position) - 2Always - one state variable per component is the rule
- 3Never - objects in state are forbidden
Explanation
Grouping related values avoids forgetting to update one of them. Unrelated values are simpler as separate useState calls.