Skip to content

Commit e6d5211

Browse files
committed
docs: correct inaccurate infinite loop claim in set-state-in-render
1 parent abe931a commit e6d5211

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/content/reference/eslint-plugin-react-hooks/lints/set-state-in-render.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ function Counter({max}) {
8888
}
8989
```
9090
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.
9292
9393
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:
9494

0 commit comments

Comments
 (0)