Browse Source

Clarify the definition of "inside conditions" (#3542)

* Clarify the definition of "inside conditions"

* Make clarification more concise

Co-authored-by: Ricky <rickhanlonii@gmail.com>

* Remove accidental extra period

Co-authored-by: Ricky <rickhanlonii@gmail.com>
main
Ty Mick 4 years ago
committed by GitHub
parent
commit
364c661385
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      content/docs/hooks-rules.md

2
content/docs/hooks-rules.md

@ -12,7 +12,7 @@ Hooks are JavaScript functions, but you need to follow two rules when using them
### Only Call Hooks at the Top Level {#only-call-hooks-at-the-top-level}
**Don't call Hooks inside loops, conditions, or nested functions.** Instead, always use Hooks at the top level of your React function. By following this rule, you ensure that Hooks are called in the same order each time a component renders. That's what allows React to correctly preserve the state of Hooks between multiple `useState` and `useEffect` calls. (If you're curious, we'll explain this in depth [below](#explanation).)
**Don't call Hooks inside loops, conditions, or nested functions.** Instead, always use Hooks at the top level of your React function, before any early returns. By following this rule, you ensure that Hooks are called in the same order each time a component renders. That's what allows React to correctly preserve the state of Hooks between multiple `useState` and `useEffect` calls. (If you're curious, we'll explain this in depth [below](#explanation).)
### Only Call Hooks from React Functions {#only-call-hooks-from-react-functions}

Loading…
Cancel
Save