LearnThatStack Ace your next interview
React · question
Question 10 of 103

What are props in React?

beginner
← All React questions
Re-explain

Props, short for properties, are read-only inputs that a parent component passes to a child component. They let data flow down the component tree.

// Parent component
function App() {
  return <Welcome name="John" age={25} />;
}

// Child component
function Welcome(props) {
  return <h1>Hello, {props.name}! You are {props.age} years old.</h1>;
}

A child treats its props as immutable. It reads them to decide what to render and never changes them. A prop can be any JavaScript value, such as a string, a number or an object. Function props work too, which is how a child tells its parent that something happened.

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

The diagram below the answer is the concept . Jump to it ↓

Tailored explanation · switch back to · ·
What should the new diagram focus on?
Guided practice for React One question at a time. Answer out loud, get graded, see what you missed.
How well did you know this?
AI:

Saved in this browser - sign in to keep your review list.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Interview lens How interviewers actually use this question

Likely follow-ups

  • How is a prop different from state? Props come from the parent and the child can't change them. State belongs to the component itself, and updating it triggers a re-render.
  • How does a child tell its parent that something changed? The parent passes a function as a prop and the child calls it with the new value. Data still flows down while events go up.
  • What goes wrong if a child mutates an object it received as a prop? The parent's data changes with no state update, so React gets no signal to re-render and the screen goes stale. Ask the parent to change it instead.
  • What is the children prop and when would you use it? Whatever sits between a component's opening and closing tags arrives as props.children. Useful for wrappers like layouts, cards and modals.
  • A prop passes through five components that never use it. How would you fix that? Call it prop drilling. Try composition first, then Context for data many components need, and mention that Context changes re-render every consumer.

What you can say

  1. Props are the inputs a parent component passes to a child, a lot like arguments to a function.
  2. You write them as attributes in JSX, so App can render Welcome with a name and an age, and Welcome reads props.name to decide what to show.
  3. They're read-only. The child never changes its props, it just renders from them, so data only flows down the tree.
  4. A prop can be any JavaScript value, like a string, a number, an object or a function.
  5. Passing a function is how the child talks back. It calls the function when something happens and the parent decides what changes.
  6. The catch is that props only go one level down, so shared data can end up threaded through layers that never use it, and that's when I'd reach for composition or Context.

Weak answers to avoid

  • Treats props and state as the same thing Props come from the parent and are read-only for the child. State is owned by the component. Blurring the two signals shaky basics.
  • Says the child can update its own props Props are read-only. If the value has to change, keep it in the parent's state and pass down a function the child calls to change it.
  • Only mentions strings and numbers Props can be any value. Leaving out function props misses how a child reports events to its parent, which is the obvious next question.
  • Recites a definition with no example Sketch a two-line parent and child out loud. It shows you've actually written components and sets up the one-way data flow point.
Interview lens

Likely follow-ups, what you can say, and the weak answers to avoid.

Sign in free to open it Free account - the lens opens as soon as you're back.

Want a quick review of the fundamentals? See the React cheatsheet.

← Back to all React questions
Pro · $10/mo

88 of 103 React answers are in Pro.

Full answers, code samples, and AI explanations that go simpler or deeper. Cancel anytime.

  • Full answers + code
  • AI explanations, simpler or deeper
  • 1,000 AI credits / month
  • Cancel anytime