diff --git a/packages/eslint-plugin-react-hooks/__tests__/ESLintRuleNoNestedComponents-test.js b/packages/eslint-plugin-react-hooks/__tests__/ESLintRuleNoNestedComponents-test.js index 380026f0ca8dc..b47635f9b2a98 100644 --- a/packages/eslint-plugin-react-hooks/__tests__/ESLintRuleNoNestedComponents-test.js +++ b/packages/eslint-plugin-react-hooks/__tests__/ESLintRuleNoNestedComponents-test.js @@ -846,6 +846,17 @@ const tests = { })) `, }, + { + code: normalizeIndent` + function useCustomHook() { + const useNestedHook = () => { + React.useRef(); + } + useNestedHook(); + useNestedHook(); + } + `, + }, ], invalid: [ { diff --git a/packages/eslint-plugin-react-hooks/src/NoNestedComponents.js b/packages/eslint-plugin-react-hooks/src/NoNestedComponents.js index e8b964fe5ab26..fce2e5de806dc 100644 --- a/packages/eslint-plugin-react-hooks/src/NoNestedComponents.js +++ b/packages/eslint-plugin-react-hooks/src/NoNestedComponents.js @@ -102,7 +102,7 @@ function isInsideComponentOrHook(node) { function isComponent(node) { const functionName = getFunctionName(node); if (functionName) { - if (isComponentName(functionName) || isHook(functionName)) { + if (isComponentName(functionName)) { return true; } }