React
Introduction to React Hooks - Custom Hooks
  •  

Rules For Hooks

PRO
Outline

Let's go over the rules for hooks before implementing your own:

1️⃣ The official rules say not to call hooks inside loops, conditions, or nested functions. Instead, always use hooks at the top level of your React function. By following this rules, you ensure that hooks are called in the same order each time a component renders.

2️⃣ Only call hooks from React functions. Don't call hooks from regular JavaScript functions. Instead, you can call hooks from React functional components or call hooks from custom hooks.

Read more about the rules for hooks here.

 

I finished! On to the next chapter