What are props in React?

Beginner

Answer

Props (short for properties) are read-only inputs passed from parent components to child components. They allow data to 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>;
}

Props characteristics:

  • Read-only (immutable)
  • Passed from parent to child
  • Can be any JavaScript value (strings, numbers, objects, functions, etc.)