- Forums
- react
- Use React Component Within The Same File As Functional Component
use this page as an example to create a function component in React. [5207], Last Updated: Mon Jun 24, 2024
cathy
Tue Sep 12, 2023
0 Comments
250 Visits
To create a very basic example of a function component in react that is within the same file, you can use this example:
function Car(props:any) {
return <h2>Hi, the car name is {props.name}</h2>;
}
JSX Code:
<Car name="Honda Civic"/>
Hope that works!