Course contentsShow
← React
Lesson 1680 of 2,39641. State Management EcosystemFree lesson

The Local-First Principle

Start with useState in the component that owns the data; only escalate when you have a concrete reason to share state.

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

  1. Start here: useState in the component
  2. If a sibling needs it: Lift to the nearest common parent
  3. If many distant components need it: Consider Context
  4. 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.