The Concept of "Composition" ("children props")
In my words : Aik custom component mai agar hum apna aik or custom component add karay ya kuch bhi dosra us kai bech mai add karay to is process ko hum composition kehtay ha...
From Chat GPT We Get :
In React, composition refers to the practice of combining simple, reusable components to create more complex ones. This is achieved by passing one component as a "child" of another component using what is known as "children props". The "children props" is a special prop in React that allows you to pass child components to a parent component as a property. This enables the parent component to render the child components within its own structure. For example, imagine you want to create a reusable Card component that can display any content inside it. You can achieve this by passing the content to be displayed as a child component to the Card component using the "children props".
function Card(props) {
return (
<div className="card">
{props.children}
</div>
);
}
function App() { return ( <Card> <h2>Card Title</h2> <p>This is the content of the card.</p> </Card> ); }
Comments
Post a Comment