ReactJS Class Components

・1 min read

Hello, I want to ask in ReactJS. What do you consider in making every Class Components in the project?

For example, I am making CRUD with SEARCH and using Backend with DjangoREST or other API Framework. So, I am requesting in the API everytime.

I want to know what components should I make to make the project well developed.

Thank you so much.


Let me check if I got your answer right: You are asking if you should make every component in React a class, right?
If that's the question, I don't think that'll be necessary. React class components are powerful but slower in performance compared with functional components. What I like to do is creating all presentational (ui) components as functional components and all the container components a class component. With this structure I have a well defined state with well declared methods in a class component that pass the props to their presentational childrens.

Tip: If you're using Redux a very useful middleware for API calls is Redux-Saga. It allows you to make asynchronous API calls with ease.

Hope this helps!

Classic DEV Post from Sep 2 '18

My VSCode Setup

Posts on editor setups are extremely popular. Here is mine.

Web developer

If you are new to DEV, we are a software blogging site visited by over 2 million developers per month.

Get Started