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 Sep 24 '17

The Git Rebase Introduction I Wish I'd Had

If you don't know what rebasing in Git is, read this before it's too late. Especially if you love cupcakes!

Boss A profile image
Web developer

Sore eyes?

dev.to now has dark mode.

Go to the "misc" section of your settings and select night theme ❤️