Sometimes we are only interested in a few properties from all the ones sent to us.
App.jsx
import { useState } from 'react'
import reactLogo from './assets/react.svg'
import viteLogo from '/vite.svg'
import './App.css'
import HelloWorld from './components/HelloWorld'
const car ={
color: "blue",
wheels:4,
engine: "diesel"
};
function App() {
return (
<>
<h1>App component</h1>
<HelloWorld color={car.color} wheels={car.wheels} engine={car.engine}/>
</>
)
}
export default App;
HelloWorld.jsx
function HelloWorld({color, engine}){
return(<>
<h2>Your car has {color} color and {engine} engine</h2>
</>);
}
export default HelloWorld;
Props.children
Another project is created
App.jsx
import './App.css'
import Parents from './components/Parents'
function App() {
return (
<>
<h1>App</h1>
<Parents/>
</>
)
}
export default App
Parents.jsx
import Daughter from "./Daughter";
import Son from "./Son"
const Parents = ()=>{
return(
<>
<Son>
<h1> I am your son</h1>
</Son>
<Daughter>
<h1> I am your daughter</h1>
</Daughter>
</>
);
}
export default Parents;