What Props Are: Arguments to Components
You'll learn how props enable components to receive and use data from their parents, just like functions accept arguments.
The Core Idea
Think of a component as a function (because it literally is one). Just as functions accept arguments to work with different data, components accept props (short for "properties") to customize what they render.
When you call a function, you pass it arguments:
function greet(name) {
return `Hello, ${name}!`;
}
greet("Alice"); // "Hello, Alice!"
When you use a component, you pass it props:
function Greeting(props) {
return <h1>Hello, {props.name}!</h1>;
}
<Greeting name="Alice" />
Props Flow Downward
Props are React's way of passing data from parent to child. The parent component decides what data to send, and the child component receives it as a single props object.
function App() {
return <Greeting name="Alice" age={25} />;
}
function Greeting(props) {
return (
<div>
<h1>Hello, {props.name}!</h1>
<p>Age: {props.age}</p>
</div>
);
}
The Greeting component receives props as an object: { name: "Alice", age: 25 }.
Why Props Matter
Without props, every component would be static and unchangeable. Props make components reusable — you can render the same component multiple times with different data, just like calling a function with different arguments.
Key Takeaway: Props are how parent components pass data to child components, turning static JSX into dynamic, reusable building blocks.