React Funtional and Class Components Difference



Functional Components

Class Components

Functional components are simple JavaScript functions that take props as arguments and return JSX.      

A class component extends from React.Component and the render function return the React element.

It is known as a stateless component since it does not have any state

A class component can also be referred to as a stateful component 

A functional component does not respond to a lifecycle event

Lifecycle events can be handled by class components

A constructor is not supported by functional components

Provide a constructor for storing state before passing props to the parent class

React provides useState()Hook for handling state functional components.

It's a bit different for class components. The this keyword is required, along with the setState() function and a constructor. 

Comparatively, functional components perform better than class components

A class component is more complex: it is an instance of React.Component with a constructor.

 

DOT NET ADDA

interested in solving the problems based on technologies like Amazon AWS ,Google Cloud, Azure and Dot related technology like asp.net, C#, asp.net core API, swagger, react js,Jquery ,javascripts, bootstrap, css,html, ms sql,IIS,WPF ,WCF,Firebase,RDLC Report etc..

إرسال تعليق (0)
أحدث أقدم