Types of React Components: All developers must know

Narender Saini
2 min readJan 5, 2020
Example of components

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 :-

  1. 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.

Example of functional components

Why Functional Components

  1. They are easy to write and easy to read.
  2. Reusable.
  3. Better performance.
  4. 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.

Example of class componets

Why Class Components

  1. Allow us to use life-cycle methods of Reactjs.
  2. Reusable.
  3. Allow us to use state.
  4. Allow to inherit or extend other class components.

--

--

Narender Saini

I am a freelancer, teacher and blogger with 4+ year experience of reactjs. https://blogreact.com/