In this lesson you will
- Pass strings, numbers, booleans, objects and functions as props
- Read props with destructuring and give them default values
- Build wrapper components with the children prop
- Explain one-way data flow and why props are read-only
Passing props and reading them
You pass props where you use the component. A fixed string goes in quotes, name="Oud oil"; anything else goes in braces: numbers price={180}, booleans inStock={false}, variables rating={stars}, arrays and objects. Writing just the name, <Badge highlighted />, passes true. React collects all of them into one object and passes it as the first argument of your function. You could write function ProductCard(props) and read props.name, but most code destructures the object straight away: function ProductCard({ name, price }).
The big mistake to avoid is passing a number as a string. price="180" passes the text "180", and price * 2 still works by luck while price + 5 gives "1805". Use price={180}. Prop names are yours to choose, in camelCase, but avoid names that already mean something on HTML elements unless you mean the same thing. If a prop is not passed at all, its value is undefined, and React shows nothing for it, which is often why a card renders with a blank space.
Console
- Console messages, errors, form data and clicked links appear here.
The Console shows the props object each card receives. Change price={60} to price="60" and the page breaks with "price.toFixed is not a function", because a string has no toFixed. That is the number-as-string mistake in action.
Sign in free to read the full lesson
You are reading the free preview. Create a free account (it takes one minute, no password) to unlock the rest of this lesson and track your progress.
Unlocks after sign-in:
- 3 more sections with live code examples
- Common mistakes to avoid
- Hands-on coding exercise with automatic checks
- Practice quiz and the graded lesson test
Free forever. No card, no paywall.
Questions people ask
What is the difference between props and state in React?
Props come from the parent and are read-only inside the component. State belongs to the component itself and changes over time, for example when a user clicks. A parent often keeps state and passes it down to children as props.
Can a child component send data back to its parent?
Not by changing props. The parent passes a function, such as onSelect, and the child calls it with the data: onSelect(product.id). The parent then updates its own state.
How many props can a React component have?
React sets no limit. A long list of props is still a warning sign that the component does too many jobs. Group related values into one object prop, or split the component into smaller pieces that each take a few props.
Should I use defaultProps for default values?
No, not for function components. React 19 removed defaultProps support for them. Use default values in the destructuring instead: ({ size = "medium" }).
Is key a normal prop I can read in my component?
No. key is used by React itself to track items in a list and is not passed to your component. If you need the id inside, pass it again under another name, such as id={p.id}. Lists and keys have their own lesson.
Sources
Facts in this lesson were checked against these official pages on 19 November 2026.
- React docs: Passing Props to a Component
- React docs: Keeping Components Pure
- React docs: Thinking in React
- React 19 upgrade guide (defaultProps removed for functions)
Code examples stay in English and run in a sandbox on your device. If you spot a mistake, tell us through the contact page.