Lifting State Up
Part of the MERN Stack Roadmap
In short
Sooner or later two components need the same data: a filter box and the list it filters, or a product card and the cart badge. Lifting state up is the simple, built-in React answer before you reach for any library.
When two sibling components need the same data, you move the state to their closest common parent and pass it down as props, keeping one source of truth.

Think of it like this
The family TV remote
Two kids each holding their own remote would fight over the same TV. So the remote lives with the parent in the middle of the sofa. Each kid asks the parent to change the channel, and both watch the same screen. The parent is the closest common component, holding the one source of truth.
Watch it happen
Moving the search text to the common parent
1/5At first SearchBar keeps query in its own state. ProductList cannot see it.
The big ideas
What you need to know
Find the common parent
Move the state to the nearest component that sits above every component that needs it.
Data down, events up
The parent passes the value down as a prop and a setter-like function, such as onQueryChange, for children to call.
One source of truth
Never keep two copies of the same state in siblings. They will drift apart.
Know when to stop
If you are passing props through four or five layers that don't use them, consider Context or a store instead.
See it in code
Walk through the code
1import { useState } from "react";2 3function SearchBar({ query, onQueryChange }) {4 return <input value={query} onChange={(e) => onQueryChange(e.target.value)} placeholder="Search products" />;5}6 7function ProductList({ products }) {8 if (products.length === 0) return <p>No matches.</p>;9 return (10 <ul>11 {products.map((p) => <li key={p._id}>{p.name} - ₹{p.price}</li>)}12 </ul>13 );14}15 16export default function ProductsPage({ allProducts }) {17 const [query, setQuery] = useState("");18 const filtered = allProducts.filter((p) =>19 p.name.toLowerCase().includes(query.toLowerCase())20 );21 22 return (23 <>24 <SearchBar query={query} onQueryChange={setQuery} />25 <ProductList products={filtered} />26 </>27 );28}1/4SearchBar holds no state. It shows the value it gets and reports changes upward.
The parent owns the search text, and both children read from it.
Save yourself the pain
Common mistakes
Oops
Keeping query in SearchBar and copying it into ProductList with an effect.
Do this instead
Lift it to the parent. Syncing two states with effects is fragile and causes extra renders.
Oops
Lifting every piece of state to App just in case.
Do this instead
Lift only as high as needed. State that one component uses should stay in that component.
Your mission
Temperature converter
Quick check
A Filters panel and a ResultsTable are siblings and both need the selected city. Where should the city state live?
Go deeper
- 1Lift cart state up so a product list and cart summary stay in sync.
- 2Pass setter functions down to the children that change the state.
- 3Notice when lifting gets painful, which is the signal to use context or a store.
More topics at this stop
Stuck on this topic? Ask an Insider
Get 1:1 guidance from people who've walked this exact path — on the InsideEdge app.