Props are the values a parent component passes to a child component in React. You pass props by writing them as JSX attributes on the child's tag. The parent decides each value, and the child receives it as a read-only input.
Pass props from the parent
To send a value down, write it as an attribute on the child's tag. This App component passes a name to a Greeting component:
function App() {
return <Greeting name="Maya" />;
}The word name is the prop name, and "Maya" is its value. The child receives both.
You can pass any JavaScript value, not only strings. Numbers, booleans, arrays, and objects all work, and non-string values go inside curly braces:
function App() {
return (
<Product
name="Desk lamp"
price={39}
tags={["home", "lighting"]}
/>
);
}The Product component now receives three props with three different types.
What props can hold
A prop is a plain JavaScript value, so almost anything fits. Strings are the only values you can pass without curly braces:
| Value | Example | How you pass it |
|---|---|---|
| String | Maya | name="Maya" |
| Number | 39 | price={39} |
| Boolean | true | inStock={true} |
| Array | ["home"] | tags={["home"]} |
| Object | { id: 7 } | item={{ id: 7 }} |
| Function | handleAdd | onAdd={handleAdd} |
The double curly braces around an object are an object literal inside a JSX expression, not a special syntax. Everything except a plain string goes inside braces.
Read props in the child
The child component receives all props as a single object. Destructure the ones you need inside the parameter list:
function Greeting({ name }) {
return <h1>Hello, {name}</h1>;
}Given the name prop "Maya", the browser shows a heading that says "Hello, Maya."
You can also accept the whole object and read properties from it, which is useful when a component forwards many props:
function Greeting(props) {
return <h1>Hello, {props.name}</h1>;
}Both versions do the same thing. Destructuring is the common choice because it names the props you expect up front. It also keeps defaults and unused props visible in one place.
Set a default value
A prop is undefined when the parent does not pass it. Give it a fallback by adding a default in the destructuring:
function Greeting({ name = "Guest" }) {
return <h1>Hello, {name}</h1>;
}Now a Greeting with no name prop shows "Hello, Guest." The default only applies when the prop is missing or undefined, not when you pass null or zero.
Pass a function to update data
Props can carry functions as well. A child that must change a parent's value receives a handler and calls it:
function AddButton({ onAdd }) {
return <button onClick={onAdd}>Add item</button>;
}The parent owns the logic and passes it down. The child only triggers it, which keeps data flowing one way while still letting children respond to interaction. You will use this pattern constantly once components start holding state.
Keep props read-only
A child should never assign to a prop. This is the pattern to avoid:
function Greeting({ name }) {
name = name.toUpperCase();
return <h1>Hello, {name}</h1>;
}Mutating a prop has no effect on the parent and breaks the one-way data flow. If a child needs to change a value, the parent owns that value and passes a way to update it down. That idea is called lifting state up.
What to learn next
See how props differ from state, then learn to lift shared values up to the parent so they can be updated in one place.
Rune AI
Key Insights
- Props are read-only values a parent passes to a child.
- Pass them as JSX attributes on the child's tag.
- Read them with destructuring inside the child function.
- Default values apply only when a prop is missing or undefined.
- Never mutate props. Lift state up to the parent to change them.
Frequently Asked Questions
What are props in React?
Can a child component change its props?
What happens if a prop is missing?
Conclusion
Passing props in React is a three step loop: pass a value on the parent's JSX tag, read it with destructuring in the child, and render it. Props keep data flowing one way, from parent to child, and stay read-only.
More in this topic
How to Build a Dropdown Menu in React
Build a React dropdown menu with the ARIA menu button pattern. Handle open and close, keyboard arrows, and clicks outside the menu.
How to Animate React Components with Motion
Animate React components with the Motion library. Set up motion, add enter, hover, and exit animations, and respect reduced motion.
Headless UI Components Explained: Logic Without Locked Styling
Understand headless UI components and how libraries like Radix give you unstyled, accessible behavior that you style yourself.