You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit e6d5211
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: src/content/reference/eslint-plugin-react-hooks/lints/set-state-in-render.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -88,7 +88,7 @@ function Counter({max}) {
88
88
}
89
89
```
90
90
91
-
As soon as `count` exceeds `max`, an infinite loop is triggered.
91
+
Although this won't cause an infinite loop (since the condition eventually becomes false), it interrupts the current render and forces React to start over, making your component slower.
92
92
93
93
Instead, it's often better to move this logic to the event (the place where the state is first set). For example, you can enforce the maximum at the moment you update state:
0 commit comments