๐ React Mastery Series โ Day 19
Lifting State Up โ Master Component Communication in React
As your app grows, components need to talk to each other.
But hereโs the rule in React:
๐ Data flows one way (Parent โ Child)
So what if two sibling components need the same data?
Thatโs where Lifting State Up comes in.
๐ค What is Lifting State Up?
Lifting State Up means moving state to the closest common parent so multiple components can share it.
Instead of each component managing its own state,
we move the state to their parent.
๐ง Why Do We Need It?
Imagine:
Component A updates data
Component B displays that data
If both are siblings, they canโt directly communicate.
Solution?
๐ Move state to Parent.
๐ Example โ Without Lifting State
function InputComponent() {
const [text, setText] = useState("");
return (
<input
value={text}
onChange={(e) => setText(e.target.value)}
/>
);
}
function DisplayComponent() {
return <h2>Text will appear here</h2>;
}
Problem:
Input has state
Display cannot access it
โ Solution โ Lift State Up
Step 1 โ Move State to Parent
import { useState } from "react";
function Parent() {
const [text, setText] = useState("");
return (
<div>
<InputComponent text={text} setText={setText} />
<DisplayComponent text={text} />
</div>
);
}
Step 2 โ Pass Props to Children
function InputComponent({ text, setText }) {
return (
<input
value={text}
onChange={(e) => setText(e.target.value)}
/>
);
}
function DisplayComponent({ text }) {
return <h2>{text}</h2>;
}
Now:
Input updates state in Parent
Parent passes updated state to Display
Both stay in sync
Clean and predictable ๐ฏ
๐ง Mental Model
Instead of:
Sibling โ Sibling
Think:
Sibling โ Parent โ Sibling
Data flows down, actions flow up.
๐ฏ When Should You Lift State Up?
โ When multiple components need same data
โ When sibling components must stay synchronized
โ When building forms
โ When managing shared UI state
โ When NOT to Lift Too Much
โ Donโt move everything to top-level unnecessarily
โ Avoid deep prop drilling (use Context if needed)
๐ง One-Liner
Lifting State Up is the process of moving shared state to the closest common parent so multiple components can access and synchronize it.
๐ How It Connects with Previous Days
โ Controlled Components (Day 18)
โ Props (Day 6)
โ Context API (Day 16)
This is the foundation of React architecture.
โ Key Takeaways
โ React follows one-way data flow
โ Shared state lives in common parent
โ Children receive data via props
โ Clean communication pattern
๐ Coming Next
Day 20 โ Conditional Rendering (Clean UI Logic Patterns)
Now we refine UI behavior like a real frontend developer ๐ฅ
About the author
Frontend Developer | React & JavaScript | Building production-ready web apps Developer with 1.5+ years of experience, currently focused on React, Redux, and full-stack development. Sharing practical tutorials, concepts, and project learnings.
Comments
Join the discussionNo comments yet. Be the first to comment.




