What are hooks in React?

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

  1. What are hooks?
  2. Why were hooks introduced?
  3. Common types of hooks
  4. Rules for hooks
  5. 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 — https://tekolio.com/what-are-hooks-in-react/

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Ateev Duggal

I am a front-end developer from India with over one year of experience in freelancing with skills like Git, HTML5, CSS3, Bootstrap 4&5, and React.