Skip to content

Commit

Permalink
Clarify the definition of "inside conditions" (reactjs#3542)
Browse files Browse the repository at this point in the history
* Clarify the definition of "inside conditions"

* Make clarification more concise

Co-authored-by: Ricky <[email protected]>

* Remove accidental extra period

Co-authored-by: Ricky <[email protected]>
  • Loading branch information
TyMick and rickhanlonii authored Feb 27, 2021
1 parent f73dcf1 commit 364c661
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion content/docs/hooks-rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -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}

Expand Down

0 comments on commit 364c661

Please sign in to comment.