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.

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.

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.
Categories: Reactjs

2 Comments

5 vscode extensions for react developers - Blog React · January 29, 2020 at 3:49 am

[…] If you want to learn types of components you can learn here. […]

Full Guide to Hooks vs Classes in React - Blog React · February 17, 2020 at 4:19 am

[…] Stateless / functional Components […]

Comments are closed.