DEV Community

Discussion on: React: class components vs function components

Collapse
 
tanth1993 profile image
tanth1993

the only thing I like Class Component is that there is a callback in setState. I usually use it when after set loading for the page :)

Collapse
 
gilfewster profile image
Gil Fewster • Edited

The equivalent in functional components is the useEffect hook, which can be setup to run a function when one or more specific dependencies change.

There is also a hook called useReducer which gives you the ability to perform complex actions and logic when dependencies change. Very useful for deriving properties from complex state.

Collapse
 
colocodes profile image
Damian Demasi

Spot on!