DEV Community

Ali Bahaari
Ali Bahaari

Posted on

Should we use "Functional" components + Hooks rather than "Class-Based" components?

What does React say?

The FAQ of React docs site encourage us to adapt to functional components and hooks:

When you’re ready, we’d encourage you to start trying Hooks in new components you write.


The only reason which never have described by even React docs in details is functional components are cleaner and much-easier-to-read ones. You can understand functionality of a component by glimpsing.

Consider you want to use componentDidMount and componentWillUnmount:

  • In class-based components these are separate methods which may need interactions with each other. Also they can't be redeclared in the component.
  • But by using useEffect hook, you can have multiple componentDidMount and componentWillUnmount functionalities in your components and therefore this and other reasons which you may have faced cause much easier codes for comprehension.

Top comments (0)