React Components
React Components
In React, a component is a reusable, self-contained piece of UI that can be composed together to build more complex user interfaces.
Functional Component:
Functional components are simpler and often used when the component doesn't need to manage state or lifecycle methods. They receive props as arguments and return JSX.
import React from 'react';
const FunctionalComponent = (props) => {
return (
<div>
<h1>{props.title} </h1>
<p>{props.description} </p>
</div>
);
};
export default FunctionalComponent;
In this example:
import React from 'react';
import FunctionalComponent from './FunctionalComponent';
const App = () => {
return (
<div>
<FunctionalComponent title="Functional Component" description="This is a functional component." />
</div>
);
};
export default App;