React hooks have been around for some time now, yet many React developers are not actively using them. I see two primary reasons behind this. The first reason is that many React developers are already involved in a large project, which requires a significant effort to migrate the entire codebase. The other reason is the familiarity with React Classes. With the experience, it feels more comfortable to keep using Classes.

In this article, we’ll look into five reasons why you should consider React Hooks.

1. You don’t have to refactor a functional component into a class component when it grows

Usually, there are times when a React component starts with a functional component, which only depends on the props and later evolves into a Class component with having a state. Changing from a functional component to a class component requires a little bit of refactoring, depending on how complex the component is.

With React Hooks, since functional components have the capability of tapping into the state, the refactoring effort will be minimal. Let’s consider the below example, a dumb component that shows a label with a count.

#render-props #react #react-hook #javascript #classes

Top 6 Reasons to Use React Hooks Instead of Classes
12.30 GEEK