All posts
ReactNovember 12, 20267 min read

React Props Explained for Beginners: Pass Data Easily

What are props in React? Learn how to pass data to components with simple examples, children, default values and common mistakes. Perfect for beginners.

F
Fepiq Team
Fepiq

What are props in React? Props (short for "properties") are the way you send data from one component to another. Think of them like the settings you give to a function. You write them like HTML attributes, and the component reads them and shows something different each time. This guide explains props from zero, with small examples you can copy.

You do not need any React experience beyond knowing that a component is a reusable piece of a web page. If that is new, read our guide on what a React component is first.

New to components? Start with this simple guide first.

What is a React component?

What are props in React?

A component is a function that returns some HTML-like code (called JSX). Without props, a component always shows the same thing. With props, you can reuse one component many times with different data.

A real-life example: a greeting card template. The layout is always the same, but you change the name on each card. The template is the component. The name is the prop.

Your first component without props

jsx
function Welcome() {
  return <h1>Hello, Sam!</h1>;
}

export default Welcome;

Line 1 creates a component named Welcome. Line 2 returns the heading to show on the page. Line 5 exports it so other files can use it. The problem: it can only ever greet Sam.

Add a prop to make it reusable

jsx
function Welcome(props) {
  return <h1>Hello, {props.name}!</h1>;
}

function App() {
  return (
    <div>
      <Welcome name="Sam" />
      <Welcome name="Priya" />
      <Welcome name="Lucas" />
    </div>
  );
}

export default App;

In line 1, the component now accepts one input called props. React fills it in for you. It is an object that holds everything you passed in. In line 2, {props.name} reads the name value; curly braces let you put JavaScript inside JSX. In lines 8 to 10, we use Welcome three times and pass a different name each time, just like an HTML attribute. The page shows three different greetings from one component.

Destructuring props (the cleaner way)

Typing props.name over and over gets tiresome. Most developers use destructuring, a JavaScript shortcut that pulls values out of an object into variables.

jsx
function Welcome({ name }) {
  return <h1>Hello, {name}!</h1>;
}

The curly braces in the parentheses say: take the name value out of the props object. Now you can write {name} directly. It works exactly the same as before, just shorter.

Passing different kinds of values

Strings go in quotes. Everything else (numbers, true/false, arrays, objects, functions) goes inside curly braces.

jsx
function ProfileCard({ name, age, isOnline, hobbies }) {
  return (
    <div>
      <h2>{name}</h2>
      <p>Age: {age}</p>
      <p>{isOnline ? "Online" : "Offline"}</p>
      <ul>
        {hobbies.map((hobby) => (
          <li key={hobby}>{hobby}</li>
        ))}
      </ul>
    </div>
  );
}

function App() {
  return (
    <ProfileCard
      name="Maria"
      age={28}
      isOnline={true}
      hobbies={["Reading", "Hiking", "Chess"]}
    />
  );
}

ProfileCard receives four props. In App, name is a string, so it uses quotes. age, isOnline and hobbies use curly braces because they are a number, a boolean and an array. Inside the card, the ternary (condition ? a : b) shows Online or Offline, and map() turns each hobby into a list item. The key helps React track each item in a list.

Value typeHow to pass itExample
StringQuotesname="Maria"
NumberCurly bracesage={28}
BooleanCurly bracesisOnline={true}
ArrayCurly braceshobbies={["a", "b"]}
FunctionCurly bracesonSave={handleSave}

Default values for props

What if someone forgets to pass a prop? You can give it a default value so the page still looks right.

jsx
function Button({ label = "Click me", color = "blue" }) {
  return <button style={{ background: color }}>{label}</button>;
}

// <Button />                  -> Click me, blue
// <Button label="Save" />     -> Save, blue

Writing = "Click me" after a name sets the fallback. If the prop is passed, React uses it. If not, React uses the default. The double curly braces in style={{ ... }} are one pair for JavaScript and one pair for the style object.

The special children prop

Anything you put between a component's opening and closing tags arrives as a prop called children. This is great for boxes, cards and layouts.

jsx
function Card({ title, children }) {
  return (
    <div className="card">
      <h3>{title}</h3>
      {children}
    </div>
  );
}

function App() {
  return (
    <Card title="Tip of the day">
      <p>Drink more water.</p>
    </Card>
  );
}

Card takes a title and children. In App, the paragraph between the Card tags becomes children, and Card prints it inside its box at the {children} spot. You can now wrap any content in the same styled card.

Props are read-only

This is the most important rule: a component must never change its own props. Props flow one way, from parent to child, like a gift. The child can use it but not alter it.

jsx
function Welcome({ name }) {
  // Wrong: name = "Someone else";
  return <h1>Hello, {name}!</h1>;
}

The commented line shows what not to do. If a value needs to change over time, use state instead. State belongs to the component itself, while props come from outside.

Not sure when to use props and when to use state? This post explains the difference with examples.

Read: Props vs State

Common beginner mistakes

  • Forgetting curly braces for non-string values: age="28" passes text, not a number. Use age={28}.
  • Writing {name} outside the function's parameters without destructuring, which gives an error that name is not defined.
  • Starting a component name with a lowercase letter. Components must start with a capital letter, like Welcome.
  • Trying to change a prop inside the child. Use state instead.
  • Misspelling a prop name. The name in the parent must match the child exactly, including capital letters.

Quick summary

  1. Props are inputs you pass to a component, written like HTML attributes.
  2. The component receives them as one object, often destructured as { name }.
  3. Strings use quotes; other values use curly braces.
  4. Default values cover missing props.
  5. children holds whatever you put between the tags.
  6. Props are read-only and flow from parent to child.

Frequently asked questions

What are props in React in simple words?+

Props are values you pass into a component so it can show different content. They work like function arguments. The parent component sends them, and the child component reads them.

What is the difference between props and state in React?+

Props come from outside the component and cannot be changed by it. State lives inside the component and can change over time, which makes the screen update. Use props to pass data in and state to remember data that changes.

Can I change props inside a component?+

No. Props are read-only in React. If you need a value that changes, store it in state or ask the parent to send a new prop value.

How do I pass a function as a prop in React?+

Put the function name in curly braces, like onSave={handleSave}. The child component can then call it, for example when a button is clicked. This is how a child tells its parent that something happened.

What is props.children in React?+

It is a special prop that contains whatever you place between a component's opening and closing tags. It lets you build wrapper components such as cards, modals and layouts that can hold any content.

Want help building a React app or learning faster? Talk to the Fepiq team.

Contact Fepiq

Get new posts in your inbox

Occasional, no-fluff notes on shipping modern software — startups, automation, Laravel, Shopify and more. No spam, unsubscribe anytime.

Keep reading

Related posts

All posts

Let's build something

Ready to ship your next product with Fepiq?

Book a free discovery call. We'll listen, ask sharp questions, and send you a proposal within 3 business days.