Course contentsShow
← React
Lesson 364 of 2,39610. useState BasicsFree lesson

State is Owned by the Component That Declares It

Only the component that calls useState can update that state—child components can only receive it via props.

State is Owned by the Component That Declares It

You'll learn: Why only the component that calls useState can update that state, and what this means for parent-child relationships.

The Core Rule

When you call useState inside a component, that state belongs exclusively to that component. No other component—not its parent, not its siblings, and definitely not its children—can directly modify that state. Only the component that declared the state can call its setter function.

Think of state ownership like a key to a locked box. The component that calls useState gets both the box (the state value) and the key (the setter function). Children can see what's inside the box if you pass it as a prop, but they never get a copy of the key.

What Children Can Do

Child components can:

  • Receive the state value through props (read-only access)
  • Receive the setter function through props (if the parent explicitly passes it)
  • Request changes by calling callbacks the parent provides

What children cannot do:

  • Access the parent's state directly
  • Create their own setter for the parent's state
  • Modify the state without the parent's involvement

Why This Matters

This ownership model creates clear boundaries. You always know where state lives and where it changes. If a bug involves state being updated unexpectedly, you only need to look at one component: the one that declared it.

Key Takeaway: State declared with useState is private to that component—children can observe it via props and interact with it through passed-down setters, but the declaring component maintains exclusive control over updates.