1

I have been reading about React hooks but I do not understand the hype around it, nor why and when should use them instead of working with a simple class. The React doc doesn't help answer my question since it only state that

The distinction between function and class components in React and when to use each one leads to disagreements even between experienced React developers.

I also can't find anything about the topic online. Can anyone explain when should we use hooks and when should we use classes?

Alessio Cantarella
  • 5,077
  • 3
  • 27
  • 34
yacine benzmane
  • 3,888
  • 4
  • 22
  • 32
  • I have been wondering the same and have been using hooks where I do not need lifecycle methods. It's not entirely that simple since you also need to consider what supporting functions your component needs and how you want to encapsulate those. The way state updates works in hooks are different from classes and you need to replace the entire state – Leon Mar 19 '19 at 11:19
  • Hooks are meant to replace class components eventually – Shubham Khatri Mar 19 '19 at 11:20

0 Answers0