Props Enable Component Reusability
What you'll learn: How props transform single-use components into flexible, reusable building blocks.
Why Props Make Components Reusable
You've learned how to pass data through props. Now here's the payoff: a component that accepts props can display different content each time you use it. Instead of writing a new component for every variation, you write one component and feed it different data.
Think of a component like a form letter template. Without props, you'd write a separate letter for every recipient. With props, you write one template with placeholders ("Dear [name]"), then fill in different names each time.
The Core Pattern
function UserCard(props) {
return (
<div>
<h2>{props.name}</h2>
<p>{props.role}</p>
</div>
);
}
// Same component, different data
<UserCard name="Alice" role="Engineer" />
<UserCard name="Bob" role="Designer" />
<UserCard name="Charlie" role="Manager" />
One UserCard component definition. Three completely different cards rendered. That's reusability.
What Makes This Powerful
Without props, you'd need AliceCard, BobCard, and CharlieCard components—all basically identical code. With props, you define the structure once and supply the data at use time.
This scales beautifully. Need 100 user cards? Still just one component definition. Your data (maybe from an array) determines how many times it renders.
The Flexibility Factor
Props don't just save typing. They let components adapt to any context. A Button that accepts label and color props can be a primary button here, a danger button there, a success button elsewhere—all from the same component code.
Key Takeaway: Props turn components from hard-coded templates into flexible, data-driven building blocks that can render infinite variations from a single definition.