Class Based Component Vs Functional Components What Is The Difference ( Reactjs )
I am new to React and I want to have a clear idea of which one to use, when it comes to components I get to see there are two types. Functional Component : import React from 'react
Solution 1:
Class Components
Class-based Components uses ES6 class syntax. It can make use of the lifecycle methods.
As you can see in the example that u have given above Class components extend from React.Component.
In here you have to use this keyword to access the props and functions that you declare inside the class components.
Functional Components
Functional Components are simpler comparing to class-based functions.
Functional Components mainly focuses on the UI of the application, not on the behavior.
To be more precise these are basically render function in the class component.
Functional Components can't have state and they can't make use of lifecycle methods.
Post a Comment for "Class Based Component Vs Functional Components What Is The Difference ( Reactjs )"