ReactJS Class Components

github logo ・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.

twitter logo DISCUSS (1)
markdown guide
 

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 Dec 2 '18

What are your programming goals for 2019?

Share your programming goals for next year!

Ajie profile image
Web developer