The Rules of Hooks

There are two important rules to be followed while writing hooks. Let's have a look!

We'll cover the following

Rules for Using Hooks

There are two rules to adhere to while using hooks.

  • Only call hooks at the Top Level, i.e., not within conditionals, loops, or nested functions.
  • Only call hooks from React functions, i.e., functional components and custom hooks.

This ESLint plugin is great to ensure you adhere to these rules within your projects.

Get hands-on with 1200+ tech skills courses.