diff --git a/packages/eslint-plugin-react-hooks/__tests__/ESLintRulesOfHooks-test.js b/packages/eslint-plugin-react-hooks/__tests__/ESLintRulesOfHooks-test.js index 260829d8ad083..f392cf61989bd 100644 --- a/packages/eslint-plugin-react-hooks/__tests__/ESLintRulesOfHooks-test.js +++ b/packages/eslint-plugin-react-hooks/__tests__/ESLintRulesOfHooks-test.js @@ -489,9 +489,12 @@ const tests = { }, { code: normalizeIndent` + import * as React from 'react'; function App() { if (shouldShowText) { const text = use(query); + const data = React.use(thing); + const data2 = react.use(thing2); return } return diff --git a/packages/eslint-plugin-react-hooks/src/RulesOfHooks.js b/packages/eslint-plugin-react-hooks/src/RulesOfHooks.js index 660d92f9ea77c..bdc23f9f885ca 100644 --- a/packages/eslint-plugin-react-hooks/src/RulesOfHooks.js +++ b/packages/eslint-plugin-react-hooks/src/RulesOfHooks.js @@ -108,7 +108,7 @@ function isUseEffectEventIdentifier(node) { } function isUseIdentifier(node) { - return node.type === 'Identifier' && node.name === 'use'; + return isReactFunction(node, 'use'); } export default {