Types of React Components: All developers must know
What is component
Component is nothing but a block of UI (i.e html ) and logic (i.e logic). Components are the core part of the reactjs. You can think a normal web page as three components i.e Header, Intro text and Footer.
Types of Components
There is basically two types of components in reactjs :-
- Functional Components also know as stateless components.
2. Class Components also know as the stateful components.
Functional Components
Functional components are also know as stateless components in reactjs. As the name suggest functional components are those components which don’t use state and return jsx.
Why Functional Components
- They are easy to write and easy to read.
- Reusable.
- Better performance.
- Easy to debug and test.
Class Components
Class components are also know as stateful components in reactjs. As the name suggest class components are those components which uses state and return jsx.
Why Class Components
- Allow us to use life-cycle methods of Reactjs.
- Reusable.
- Allow us to use state.
- Allow to inherit or extend other class components.