What is React Hooks ?

It's a special function that allows us to hook(use) into the react features and state without writing a class.

What is React Hooks ?

Table of contents

No heading

No headings in the article.

To keep it simple. It's a special function that allows us to hook(use) into the react features and state without writing a class. Which was prominent before the introduction of hooks. Hooks was integrated as the new addition in react 16.8V.

Hooks allows us to reuse the stateful logic in particular without changing the component hierarchy. A state is the current data(information) or properties of the component that needs to be tracked/recorded.

In order to use hooks, firstly we need to import particular hooks from the react. As in the picture we imported useState hook from the react. We are going to learn about our first hook namely useState hook in the next article. hook usestate.png

There are fundamental rules to use the react hooks.

  • Hooks can only be called inside react function component.

  • Use hook only at the top level of the functional component before it returns.

  • Don't conditionalize the hooks. Simply! hooks cannot be conditional.