• Home
  • Recent Q&A
  • Java
  • Cloud
  • JavaScript
  • Python
  • SQL
  • PHP
  • HTML
  • C++
  • Data Science
  • DBMS
  • Devops
  • Hadoop
  • Machine Learning
in React JS by
Q:

What are the differences between the Class component and Functional component?

1 Answer

0 votes
by

Ans.

Parameter Class Component Functional Component
Syntax This component requests you to extend from React. Component to create render function that in turn returns a react element It is just a plain JavaScript function that accepts props as their arguments and returns the react element.
Life cycle hooks Lifecycle hooks are created from the React Component. This class component makes lifecycle hooks available in it. We cannot use lifecycle hooks in a functional component.
Readability They are very difficult to test and read They are much easier to test and read

Related questions

0 votes
asked Mar 30, 2020 in React JS by amita rallin
  • #react-components
  • #react-function
0 votes
asked Nov 26, 2019 in React JS by AdilsonLima
0 votes
asked Nov 26, 2019 in React JS by AdilsonLima
...