What are difference between functional component and class components?

Answer

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>
)
}
}

 

 

All react js Questions

Ask your interview questions on react-js

Write Your comment or Questions if you want the answers on react-js from react-js Experts
Name* :
Email Id* :
Mob no* :
Question
Or
Comment* :
 





Disclimer: PCDS.CO.IN not responsible for any content, information, data or any feature of website. If you are using this website then its your own responsibility to understand the content of the website

--------- Tutorials ---