DEV Community

Mihir Chhatre
Mihir Chhatre

Posted on

Intro to Hooks

Using hooks in React can be daunting 😰.
My goal, through this series, is to simplify the different hooks used in React, allowing folks to start implementing these concepts into their builds.

Since this is Part 1 of the series, let's scratch the surface on hooks.

The React documentation defines hooks as -
Functions that let you β€œhook into” React state and lifecycle features from function components.

The above definition will make a lot more sense as we go through this series but it is important to remember a few important points when using any hook in React -->

  • Hooks can only be used inside function components and they cannot be used inside class components.

  • Hooks must execute in the same order in each component render. (This essentially means you cannot use a hook inside a conditional block such as 'if'.)

You can always reference the official React documentation to learn more about hooks but since series is about understanding the different hooks, I am jumping right into one of the most widely used hooks - the State Hook.

Top comments (0)