What if you could change one thing and watch it update everywhere instantly?
Why Passing props to components in React? - Purpose & Use Cases
Imagine you have a webpage with many parts, and you want to show different messages in each part. You try to write the same message again and again inside each section manually.
Manually copying and changing content everywhere is slow and easy to mess up. If you want to change the message, you must find and update every spot, which wastes time and causes mistakes.
Passing props lets you send data to components like giving them a note to read. Components then show the right message automatically, making your code cleaner and easier to update.
function GreetingAlice() {
return <div>Hello, Alice!</div>;
}
function GreetingBob() {
return <div>Hello, Bob!</div>;
}function Greeting(props) {
return <div>Hello, {props.name}!</div>;
}
<Greeting name="Alice" />
<Greeting name="Bob" />You can create flexible components that show different content without rewriting code, making your app easier to build and maintain.
Think of a birthday card template where you just change the name and message for each friend instead of making a new card from scratch every time.
Passing props sends data to components to customize their output.
This avoids repeating code and makes updates simple.
It helps build flexible, reusable UI parts.