Skip to content

React Props Explained: Pass Data to Components, Default Values and children

NeedMyTools Academy

Sign in free to read the full lesson

Sign in or create a free account

Free forever. No card, no paywall.

A component that always shows the same text is not much better than HTML. Props are what make components useful: they are the values a parent passes to a child, written like HTML attributes, <ProductCard name="Oud oil" price={180} />. The child receives them as one object and uses them in its JSX. With props, one ProductCard component can show a thousand different products, and one Card can wrap any content you give it. This lesson covers passing and reading props, default values, the special children prop, passing whole objects and functions, and the rule that a component must never change its own props.

Quick answer

Pass props to a component like attributes: strings in quotes, everything else in curly braces, as in <Price amount={45} currency="AED" />. The component receives one object, usually destructured in the parameter list: function Price({ amount, currency = "AED" }), where = "AED" is a default used when the prop is missing. Whatever you put between the opening and closing tags arrives as the children prop. Props flow one way, from parent to child, and are read-only: to change what a child shows, the parent passes different props.

30 min read and practice · Content checked on 19 November 2026

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.

Try it: One ProductCard, three products
Code
ResultUpdates as you type
Console
  1. 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
Sign in or create a free account

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.

Code examples stay in English and run in a sandbox on your device. If you spot a mistake, tell us through the contact page.