From d8c7fb6b7669fda2cba05cdf79e21bff8f2d9102 Mon Sep 17 00:00:00 2001 From: Ismail Memon Date: Fri, 17 Apr 2026 17:48:35 +0500 Subject: [PATCH] docs: fix incorrect infinite loop claim in set-state-in-render --- .../eslint-plugin-react-hooks/lints/set-state-in-render.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/reference/eslint-plugin-react-hooks/lints/set-state-in-render.md b/src/content/reference/eslint-plugin-react-hooks/lints/set-state-in-render.md index 7517d5f9286..ce2239e4fbc 100644 --- a/src/content/reference/eslint-plugin-react-hooks/lints/set-state-in-render.md +++ b/src/content/reference/eslint-plugin-react-hooks/lints/set-state-in-render.md @@ -88,7 +88,7 @@ function Counter({max}) { } ``` -As soon as `count` exceeds `max`, an infinite loop is triggered. +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. 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: