- Create Person folder under src folder
- Add Person.js file and add below Code
import React from 'react';
const person =(props)=>{
return(
<div>
<p>I'm a {props.name} and i am {props.age} years old!</p>
<p>{props.children}</p>
</div>
);
}
export default person;
- Open App.js file and update code as below
import React from 'react';
import './App.css';
import Person from './Person/Person';
function App() {
return (
<div className="App">
<Person name="adi" age="29"/>
<h1>Props children Example</h1>
<Person name="pavan" age="27"><b>My Hobbies: Farming</b></Person>
<Person name="nani" age="30"/>
</div>
);
}
export default App;
No comments:
Post a Comment