Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
docs: correct inaccurate infinite loop claim in set-state-in-render
  • Loading branch information
Assamee committed Apr 17, 2026
commit e6d52111750a5fd04954bc28a8354b99bb3f4e15
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ function Counter({max}) {
}
```

As soon as `count` exceeds `max`, an infinite loop is triggered.
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.

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:

Expand Down
Loading