Course contentsShow
← React
Lesson 218 of 2,3967. Props FundamentalsFree lesson

Multiple Props on One Component

Components can receive any number of props, each with different types: strings, numbers, objects, arrays, or functions.

Multiple Props on One Component

What you'll learn: How a single React component can receive and use several different props at once, just like a function can accept multiple arguments.

The Core Idea

You've already learned that components accept props as arguments. But you're not limited to just one! A component can receive as many props as you need—strings, numbers, booleans, arrays, objects, or even functions. Each prop becomes a separate property on the props object.

Think of it like ordering a custom sandwich: you specify the bread type, meat, cheese, and toppings all in one order. Similarly, you pass multiple pieces of data to configure a component exactly how you want it.

The Pattern

When passing multiple props, you simply add more attributes to your component:

<UserCard 
  name="Alice" 
  age={28} 
  isActive={true}
  hobbies={['reading', 'hiking']}
/>

Inside the component, all these values arrive together in the props object:

function UserCard(props) {
  return (
    <div>
      <h2>{props.name}</h2>
      <p>Age: {props.age}</p>
      <p>Status: {props.isActive ? 'Active' : 'Inactive'}</p>
      <p>Hobbies: {props.hobbies.join(', ')}</p>
    </div>
  );
}

Why This Matters

Multiple props let you create flexible, reusable components. Instead of hardcoding values, you pass different combinations of data to the same component. The UserCard above can display any user's information—you just change the props you pass in.

Key Takeaway: Components can accept any number of props with different data types, making them highly configurable and reusable throughout your application.