Props are the values a parent component gives a child component through JSX. A child reads those values to decide what to render; if the parent has different values on a later render, the child receives those instead.
What are props in React?
Props are a component’s inputs, supplied by its parent. They let the same component render different content or behave differently depending on the values it receives. React describes props as similar to function arguments: the parent provides them, and the child uses them.
A prop can hold a string, number, object, array, function, or JSX value. In JSX, you write a prop as an attribute on the component tag.
How do I pass props to a component?
In this example, Profile is the parent. It passes a person object and a size number to Avatar:
Quick wins for a faster PC:
Repair Windows errors before they cause bigger problemsFix Now →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Clear out junk files and repair common Windows errorsFree Scan →#1 Best Overall
function Avatar({ person, size }) {
return (
<img
src={person.imageUrl}
width={size}
height={size}
alt={person.name}
/>
);
}
function Profile() {
return (
<Avatar
person={{ name: 'Lin', imageUrl: '/lin.jpg' }}
size={80}
/>
);
}
The parent writes the values on <Avatar ... />; the child receives them when React renders Avatar. Use curly braces in JSX when passing a JavaScript expression, such as an object or number. A string can also be written directly as an attribute, for example <Greeting name="Lin" />.
How do I access props in a function component?
A function component receives one props object as its parameter. Destructuring lets you pull out the properties you need by name:
function Avatar(props) {
return <img src={props.person.imageUrl} alt={props.person.name} />;
}
This is equivalent to accessing the object’s properties directly. The earlier function Avatar({ person, size }) version uses JavaScript destructuring for convenience; destructuring itself is not special React behavior.
How do default prop values work?
You can give a destructured parameter a default value. Here, the avatar uses a size of 100 if the caller omits size or passes undefined:
Rank #3
function Avatar({ person, size = 100 }) {
return <img src={person.imageUrl} width={size} height={size} alt={person.name} />;
}
The default does not apply when the caller passes null or 0; those are actual values, not an omitted or undefined value.
What is children in React?
When a component has nested JSX between its opening and closing tags, React passes that content to it as the children prop. This makes wrapper components such as cards or panels reusable with different contents:
Rank #4
function Card({ children }) {
return <section className="card">{children}</section>;
}
function ProfileCard() {
return (
<Card>
<h2>Lin</h2>
<p>Frontend developer</p>
</Card>
);
}
The JSX inside <Card>...</Card> becomes Card’s children, which it can render wherever appropriate.
Should I forward props with spread syntax?
JSX spread syntax can pass an object’s properties along to another component. For example, <Avatar {...props} /> forwards the properties in props to Avatar. This can reduce repetitive forwarding when it is intentional, but use it selectively: passing only the values a component actually needs makes its inputs easier to see. If a component mainly relays information it does not use, consider whether nested JSX and children would express the composition more clearly.
Best Value
How are props different from state and context?
Choose based on who supplies the value, whether the component changes it through interaction, and how far it must travel in the component tree.
| Concept | Where the value comes from | When it fits |
|---|---|---|
| Props | A parent passes values to a child. | Use for explicit inputs a component needs from its parent. |
| State | A component’s own changing memory. | Use for information the component updates in response to interaction or other events. A parent can also own state and pass its current value to children as props. |
| Context | An ancestor makes a value available to descendants. | Consider it when many descendants need the same information and passing it through intermediate components becomes cumbersome. |
Props are inputs, not something a child edits
Props are read-only snapshots for a particular render. A child should not change its props; when a value changes, the parent supplies the new value on a render. React’s Passing Props to a Component guide states: “Props are read-only snapshots in time: every render receives a new version of props.”
Use context for a specific data-flow problem
Ordinary props make the parent-to-child path visible. If the same value must be carried through several intermediate components that do not use it, that explicit forwarding can become verbose; React context can make the value available to descendants without threading it through each layer. Context is an alternative for that situation, not a replacement for straightforward props.
For a broader view of how props and state fit into component design, see React’s Thinking in React guide. React’s Rules of React also explain the expectation that render inputs are treated immutably.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




