Independent Updates: The Key Decision Factor
What you'll learn: How to decide between multiple useState calls or a single state object by analyzing whether state pieces update together or separately.
The Core Decision Rule
When choosing how to structure your state, ask yourself one critical question: Do these values update independently, or do they always change together?
If two pieces of state can change at different times, in different event handlers, or for different reasons, they should be separate useState calls. If they always update as a unit, consider grouping them in a single object.
Why This Matters
Imagine a user profile form with firstName, lastName, and isOnline status. The name fields update when the user types. The online status updates when they connect/disconnect. These update at completely different times, triggered by different events.
// ✅ Good: Independent updates
const [firstName, setFirstName] = useState('');
const [lastName, setLastName] = useState('');
const [isOnline, setIsOnline] = useState(false);
// Easy to update just firstName
setFirstName('Jane');
// Easy to update just online status
setIsOnline(true);
If you forced them into one object, every update would require spreading the entire object — even though the updates are unrelated.
The Grouping Test
Values should share state when they're conceptually related and update together. For example, form coordinates that move as a pair:
// Makes sense together: always updated as a unit
const [position, setPosition] = useState({ x: 0, y: 0 });
Key Takeaway: Choose multiple useState calls when state pieces have independent lifecycles and update at different times. Group into objects only when values logically belong together and update simultaneously.