Created
February 13, 2025 07:16
-
-
Save balvinder294/8d0b662bd549524840949781ca5c032a to your computer and use it in GitHub Desktop.
Example of using props as in article https://tekraze.com/understanding-states-and-props-in-reactjs-component/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
function Greeting(props) { | |
return ( | |
<h1>Hello, {props.name}!</h1> | |
); | |
} | |
function ParentComponent() { | |
const name = "Alice"; // Example of data that could be dynamic | |
return ( | |
<div> | |
<Greeting name={name} /> | |
<Greeting name="Bob" /> | |
</div> | |
); | |
} | |
export default ParentComponent; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment