Choosing the Right State Location
Apply a decision framework: local state, lifted state, or global state.
Welcome
In this lesson you will learn a practical decision framework for deciding whether state belongs in a single component, a common ancestor, React Context, or a global state library.
Step 1: Who Uses This State?
First ask: which components render using this state? List them. If only one component uses it, keep state local in that component.
All lessons in this course
- Lifting State Up: Principles & Examples
- Prop Drilling: When It Hurts & When It's Fine
- Sibling Communication Patterns
- Choosing the Right State Location