In React, props (short for “properties”) are used to pass data from a parent component to a child component.
📦 How Props Work
-
Parent sends props:
<Greeting name="BloggerSpace" /> -
Child receives props:
function Greeting(props) { return <h1>Hello, {props.name}!</h1>; } -
Result:
Renders: Hello, BloggerSpace!
🧠 Key Points
- Props are read-only (immutable inside the child).
- Used to make components reusable and dynamic.
- Can be any data type: string, number, object, function, etc.
🧰 Props with Destructuring (cleaner syntax)
function Greeting({ name }) {
return <h1>Hello, {name}!</h1>;
}
Props help build flexible and maintainable component hierarchies.