Skip to content
Guest
Learn React · Course Syllabus Show lessons
Hooks & Architecture · 8 min read · Intermediate

Lifting State Up & Component Composition

Share state cleanly between sibling components by lifting it to their nearest common parent and composing via children.

What you'll learn

  • Move shared state to the closest common parent component
  • Pass state values down and update callbacks up
  • Use the children prop to avoid unnecessary prop drilling

When two sibling components (like <SearchBar /> and <CourseList />) need to stay in sync, lift the state up to their nearest common parent (<CatalogPage />). The parent owns query, passes query and onChange to <SearchBar />, and passes the filtered list to <CourseList />.

Fill-in-the-Blank Exercise

Render Nested Children

Accept title and children in Card and render children inside the wrapper.

function Card({ title,  }) {
return <section><h3>{title}</h3>{}</section>;
}

Live Composition Playground

Shared Parent State Between Siblings
Live Result
Console Output

No console output yet. Try calling console.log(...) in JS.

Check Your Understanding

Score: 0 / 1

1. When two sibling React components need to share and update the same state, where should that state live?

Study Workspace

Finished this lesson?

Your progress is saved locally in your browser, no account needed.

Search courses, lessons, and references

Type to search across all courses, lessons, and quick references.

Press Esc to close Powered by Pagefind