To pass props to a component and access them:
Example:
// Parent Component
import React from 'react';
import Greeting from './Greeting';
const App = () => {
return <Greeting name="John" />;
};
export default App;
// Child Component (Greeting.js)
import React from 'react';
const Greeting = (props) => {
return <h1>Hello, {props.name}!</h1>;
};
export default Greeting;