To create a functional component in React, follow these steps:
import React from 'react';
const MyComponent = () => {
return (
<div>
<h1>Hello, I am a functional component!</h1>
</div>
);
}
export default MyComponent;
Here's an example of a complete functional component:
import React from 'react';
const MyComponent = () => {
return (
<div>
<h1>Hello, I am a functional component!</h1>
</div>
);
}
export default MyComponent;
You can now use this functional component in other components by importing it and including it in the JSX markup.