MyInternships.in

Components & Props

React Props

Props are the read-only inputs a parent passes down to a child component. They arrive as a single object and are the primary way data flows through a React app — always downward, from parent to child.


What is Props in React?

Props are the read-only inputs a parent passes down to a child component. They arrive as a single object and are the primary way data flows through a React app — always downward, from parent to child.

Why Props matters

Props are what make components reusable. One Card component with different props renders a job card, a course card and a company card, instead of three near-identical components.

Props example

Passing and reading props
JSX
function JobCard({ title, company, stipend, remote = false }) {
  return (
    <div className="card">
      <h3>{title}</h3>
      <p>{company} · ₹{stipend}/month</p>
      {remote && <span className="tag">Work from home</span>}
    </div>
  );
}

<JobCard title="Frontend Intern" company="Zoho" stipend={15000} remote />

How this works

Strings are passed in quotes; anything else — numbers, booleans, arrays, objects, functions — goes in braces. Writing remote on its own is shorthand for remote={true}. The default value in the destructuring applies when the prop is omitted.

Key points to remember

  • Props are immutable inside the child — never assign to props.something.
  • Destructure in the parameter list for readable code.
  • Pass functions down as props to let a child talk back to its parent.
  • Spread an object of props with {...obj} when forwarding many at once.

Common mistakes with Props

  • Mutating a prop instead of asking the parent to change its state.
  • Passing stipend="15000" as a string and then doing arithmetic on it.
  • Spreading unknown props onto a DOM element, producing React warnings about invalid attributes.

React Props— Interview Questions & FAQs

What is the difference between props and state?+

Props are passed in from the parent and are read-only inside the component. State is owned and changed by the component itself. If a value never changes from inside, it should be a prop.

Can a child change a prop?+

No. The child must call a function the parent passed down, and the parent updates its own state. This one-way flow is what keeps React apps predictable.

Related React Topics

Keep learning with these closely related lessons.

Ready to use your React skills?

Find verified React internships and fresher developer jobs across India.

Browse React Internships