Skip to content

Commit d8c7fb6

Browse files
docs: fix incorrect infinite loop claim in set-state-in-render
1 parent 40ea071 commit d8c7fb6

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+
When `count` exceeds `max`, this schedules a state update during render. This is still an anti-pattern because rendering should stay pure, and state updates should happen in an event handler or effect instead.
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)