About Lesson
What is Props in React?
Props (short for properties) are a way to pass data from a parent component to a child component in React. They are read-only and cannot be modified by the child component, ensuring a unidirectional data flow.
JavaScript
import React from "react";
function Greeting(props) {
return <h1>Hello, {props.name}!</h1>;
}
function App() {
return (
<div>
<Greeting name="Amit" />
<Greeting name="Anjali" />
</div>
);
}
export default App;