BeginnerCoder

Lesson 2 — Props

Props are a component's inputs

Props (short for properties) are values a parent passes to a component, written like HTML attributes: <Greeting name="Alex" />. The component receives them as one object, usually destructured right in the parameter list. Curly braces {…} inside JSX insert a JavaScript value into the markup.

function Price({ amount }) {
  return <span>{amount} USD</span>;
}
<Price amount={5} />  // shows: 5 USD

Why it matters: props let one component show different data — the same card for every product.

Want it another way?
Task

Render a second Greeting for Sam. The preview should show "Hi, Alex!" and "Hi, Sam!".

← Back
Next →
Test your knowledge

A quick 3-question quiz on this lesson — instant feedback.

Enjoying this lesson? Share it.