The Local-First Principle
You'll learn: Why your default instinct should be useState in the component that needs the data, not immediately reaching for global state.
What Does "Local-First" Mean?
When you need state in React, your first question shouldn't be "Where should I put this in my global store?" — it should be "Does this data truly need to be shared?"
The principle: Start with useState in the component that owns and uses the data. Only escalate to lifting state up, context, or external state managers when you have a concrete reason to share that state with other parts of your app.
Why This Matters
Local state is:
- Easier to reason about: The data lives next to the logic that uses it
- Easier to test: No need to mock global stores
- Easier to refactor: Moving or deleting a component takes its state with it
- Better for performance: No unnecessary re-renders in unrelated components
Think of it like storing belongings: keep your toothbrush in your bathroom, not in a communal warehouse just because you might share it someday.
The Escalation Path
- Start here:
useStatein the component - If a sibling needs it: Lift to the nearest common parent
- If many distant components need it: Consider Context
- If it's truly global, complex, or needs persistence: Reach for Redux, Zustand, etc.
Most state never needs to leave step 1.
The Anti-Pattern
Don't put form input values, toggle states, or temporary UI flags in a global store just because you can. That's premature optimization and creates unnecessary coupling.
Key Takeaway: Default to useState where the data is used; escalate only when sharing is required, not when it's merely possible.