The functional component and class component has more role at react.
, functional components were called stateless components and were behind class components on a feature basis.
After the introduction of Hooks, functional components are equivalent to class components.
functional components are the new trend, the react team insists on keeping class components in React.
Functional components are nothing but JavaScript functions and therefore can be declared using an arrow function.
We can differentiate between functional component and class component by code
Below the code of functional component
function card(props){
return(
<div className="main-container">
<h2>Title of the card</h2>
</div>
)
}
const card = (props) =>{
return(
<div className="main-container">
<h2>Title of the card</h2>
</div>
)
}
Below the code of class component,
class Card extends React.Component{
constructor(props){
super(props);
}
render(){
return(
<div className="main-container">
<h2>Title of the card</h2>
</div>
)
}
}