Closed
Description
React version: 18.2.0
Steps To Reproduce
-
Use a hook inside a
do/while
loop. -
You'll see that it's not considered a violation of the rule.
Code example:
function ComponentWithHookInsideDoWhile() {
do {
useHookInsideLoop();
} while (true);
}
The current behavior
The react-hooks/rules-of-hooks
does not consider hook usage inside a do/while
loop a violation.
The expected behavior
I expected that I'd see the following ESLint error:
React Hook useHookInsideLoop() may be executed more than once.
Possibly because it is called in a loop.
React Hooks must be called in the exact same order in every component render.