Skip to content
Learn Netverks

Lesson

Step 26/36 72% through track

lifting-vs-colocation

Lifting state vs colocation

Last reviewed Jun 1, 2026 Content v20260601
Track mode
client_react
Means
In-browser React TSX
Reading
~1 min
Level
intermediate

This lesson

This lesson teaches Lifting state vs colocation: the concepts, APIs, and habits you need before advancing in React.

Without Lifting state vs colocation, you will struggle to read or extend React codebases and playground exercises.

You will apply Lifting state vs colocation in contexts like: SPAs, dashboards, design-system-driven products, and React Native mobile apps.

Write TypeScript/TSX, click Run in browser—React 18 loads from CDN, JSX compiles in the tab, UI renders in the preview root, and printOutput feeds the terminal.

When you can explain the previous lesson's ideas without copying starter code.

Colocation keeps state as close as possible to where it is used—toggle open inside the dropdown, field draft inside the input. Lifting state moves shared state to the nearest common ancestor so siblings stay in sync.

When to colocate

  • UI-only state no sibling needs (accordion open, hover)
  • Encapsulated behavior you might reuse elsewhere

When to lift

  • Two components must reflect the same value (filter + list)
  • Parent orchestrates a workflow (wizard step index)

Lifting too early creates “prop drilling” and wide parent components. Colocating too late duplicates state and causes bugs when copies diverge.

Rule of thumb

Start colocated; lift only when a second consumer appears. If lifting crosses many layers, consider context or a small store—not immediate Redux for every app.

Self-check

  1. Should modal open state live in the page or inside Modal?
  2. Give an example where lifting is required.

Interview tip Lesson completion confidence

Can you explain this lesson in 30 seconds without reading notes?

Not saved yet.

Playground

Runs in your browser in a sandboxed frame. Backend runners appear when this track’s profile allows them.

Check yourself

Multiple choice — immediate feedback.

Discussion

Past discussion is visible to everyone. Only logged-in users can post comments and replies.

Starter discussion topics

  • Colocate first rule?
  • When lift anyway?

Sign up or log in to post comments and sync lesson progress across devices.

No discussion yet. Be the first to ask a question.

Jump