Before React 16.8, when hooks in React were not introduced, managing state and using lifecycle methods were only possible by the Class Components that tend to complicate things as we move with our App in React.
But after the introduction of hooks in version 16.8, managing state and using lifecycles methods became the easiest things to do in a React App, and it is only that which keeps our code clean and readable, without that ‘this’ keyword which was there in almost every other line.
In this blog, we will discuss everything related to hooks. Let’s begin
Index
- What are hooks?
- Why were hooks introduced?
- Common types of hooks
- Rules for hooks
- Conclusion
What are hooks?
As already told, hooks are an addition to the Functional Components through which we can work with states and other React features without first converting them into classes as it was the general condition in Class Components.
One point to note is that we don’t have to make any other change in our component except for one thing, we have to write our Apps in functional components as hooks can’t be used in Class Components.
Introduction of Hooks in functional components does not mean the end of Class Components, developers of React gave us an option that we can do everything including managing state and lifecycle methods using both the Components, and it is up to us which one we prefer to use.
Why were hooks introduced?
There were many problems that developers were facing while using the Class Components. They vary depending upon the user and the type of App they are making.
You can continue reading this blog on our official website
Top comments (0)