Skip to content

Commit e002fc7

Browse files
committed
fix: Don't consider Hooks as Components
1 parent 7cd66c3 commit e002fc7

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

packages/eslint-plugin-react-hooks/__tests__/ESLintRuleNoNestedComponents-test.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -846,6 +846,17 @@ const tests = {
846846
}))
847847
`,
848848
},
849+
{
850+
code: normalizeIndent`
851+
function useCustomHook() {
852+
const useNestedHook = () => {
853+
React.useRef();
854+
}
855+
useNestedHook();
856+
useNestedHook();
857+
}
858+
`,
859+
},
849860
],
850861
invalid: [
851862
{

packages/eslint-plugin-react-hooks/src/NoNestedComponents.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ function isInsideComponentOrHook(node) {
102102
function isComponent(node) {
103103
const functionName = getFunctionName(node);
104104
if (functionName) {
105-
if (isComponentName(functionName) || isHook(functionName)) {
105+
if (isComponentName(functionName)) {
106106
return true;
107107
}
108108
}

0 commit comments

Comments
 (0)