diff --git a/packages/eslint-plugin-react-hooks/__tests__/ESLintRulesOfHooks-test.js b/packages/eslint-plugin-react-hooks/__tests__/ESLintRulesOfHooks-test.js index 4376d01d824a8..9152999f647c3 100644 --- a/packages/eslint-plugin-react-hooks/__tests__/ESLintRulesOfHooks-test.js +++ b/packages/eslint-plugin-react-hooks/__tests__/ESLintRulesOfHooks-test.js @@ -550,6 +550,18 @@ const tests = { // TODO: this should error but doesn't. // errors: [genericError('useState')], }, + { + code: normalizeIndent` + // Valid because the hook is outside of the loop + const Component = () => { + const [state, setState] = useState(0); + for (let i = 0; i < 10; i++) { + console.log(i); + } + return
; + }; + `, + }, ], invalid: [ {