π΅ React Props Explained:
π΅ React Props Explained: The Power of Data Sharing Between Components

When building applications in React, props play a major role in making components reusable, dynamic, and flexible. They allow you to pass data from one component to another β just like arguments to a function.
If you're learning React, understanding props is essential. In this beginner-friendly guide, youβll learn what props are, why they matter, and how to use them the right way.
βοΈ What Are Props in React?
Props (short for properties) are used to send data from a parent component to a child component.
They are read-only, meaning a child component cannot modify the props it receives.
Think of props as:
Inputs that customize how a component behaves or displays content.
π Why Are Props Important?
Props help you:
πΉ Pass dynamic data
πΉ Reuse components in different ways
πΉ Make components flexible and customizable
πΉ Keep your app organized and modular
Without props, your UI would be static and repetitive.
π¦ How Do Props Work?
1οΈβ£ Parent component sends data
2οΈβ£ Child component receives data
3οΈβ£ Child displays or uses that data
π§© Example: Passing Props
β Parent Component (App.jsx)
import Welcome from "./Welcome";
function App() {
return (
<div>
<Welcome name="Sagar" />
<Welcome name="React Developer" />
</div>
);
}
export default App;
β Child Component (Welcome.jsx)
function Welcome(props) {
return <h1>Hello, {props.name} π</h1>;
}
export default Welcome;
Hereβs what happens:
The parent passes the value
"Sagar"as a prop.The child component displays it.
Same component, different outputs β thanks to props!
π§ Destructuring Props
You can simplify your code using destructuring:
function Welcome({ name }) {
return <h1>Hello, {name} π</h1>;
}
This makes the component cleaner and easier to read.
ποΈ Passing Multiple Props
You can pass as many props as you want:
<UserProfile name="Anita" age={22} job="Frontend Developer" />
Child component:
function UserProfile({ name, age, job }) {
return (
<div>
<h2>{name}</h2>
<p>Age: {age}</p>
<p>Job: {job}</p>
</div>
);
}
π Props vs State
| Feature | Props | State |
| Can be changed? | β No (read-only) | β Yes |
| Owned by | Parent component | Component itself |
| Used for | Passing data | Managing dynamic data |
They work together to build powerful, reactive UI.
π Props with Functions
Props are not just data β you can also pass functions as props!
Parent:
function App() {
const handleClick = () => alert("Button Clicked!");
return <Button onClick={handleClick} />;
}
Child:
function Button({ onClick }) {
return <button onClick={onClick}>Click Me</button>;
}
This is how React handles communication from child β parent.
π Props Are Immutable
One golden rule:
A child must never change its props.
Bad β:
props.name = "John";
Good β:
// Use state or callback if you need changes
π¨ Default Props
You can assign default values to props:
function Greeting({ name = "Guest" }) {
return <h1>Welcome, {name}</h1>;
}
π― Conclusion
Props are one of the core building blocks of React, enabling:
β Reusable components
β Clean and structured UI
β Dynamic and flexible layouts
β Smooth parent-to-child data flow
Master props β master component communication β master React.



