
Full-Stack React, TypeScript, and Node
By :

In this section, we will discuss some of the differences between the class way and the Hooks way of writing code in React. We will see why the React team decided Hooks was the way forward. Learning these details will give us confidence in using Hooks in our own code.
If you look at the class-based lifecycle methods, not only are there many to remember and understand, you can also see that for each class component you would have a pretty much unique implementation of lifecycle functions. This makes code reuse difficult to do with classes. With Hooks, we also have many different built-in Hooks we can use and need to know. However, they are not component specific and can be reused for different components at will. This is the key motivator for using Hooks. Code reuse is much easier because the Hooks are not tied to any specific class. Each Hook is focused on providing a specific capability or functionality,...