Home / Function/ isHook() — react Function Reference

isHook() — react Function Reference

Architecture documentation for the isHook() function in RulesOfHooks.ts from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  3fc9f24c_035f_b907_304f_45903ee4e5d7["isHook()"]
  47fb9f02_49dd_1d0d_5027_9353a6a77f1e["RulesOfHooks.ts"]
  3fc9f24c_035f_b907_304f_45903ee4e5d7 -->|defined in| 47fb9f02_49dd_1d0d_5027_9353a6a77f1e
  e33d7f9c_2333_764f_8ca1_79868b065cbf["isInsideComponentOrHook()"]
  e33d7f9c_2333_764f_8ca1_79868b065cbf -->|calls| 3fc9f24c_035f_b907_304f_45903ee4e5d7
  be7612d8_31aa_c40a_35d5_89fd476ab28a["rule.create()"]
  be7612d8_31aa_c40a_35d5_89fd476ab28a -->|calls| 3fc9f24c_035f_b907_304f_45903ee4e5d7
  c3a2d81b_4f68_8ace_b594_6a91749d2d46["isHookName()"]
  3fc9f24c_035f_b907_304f_45903ee4e5d7 -->|calls| c3a2d81b_4f68_8ace_b594_6a91749d2d46
  style 3fc9f24c_035f_b907_304f_45903ee4e5d7 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/eslint-plugin-react-hooks/src/rules/RulesOfHooks.ts lines 37–51

function isHook(node: Node): boolean {
  if (node.type === 'Identifier') {
    return isHookName(node.name);
  } else if (
    node.type === 'MemberExpression' &&
    !node.computed &&
    isHook(node.property)
  ) {
    const obj = node.object;
    const isPascalCaseNameSpace = /^[A-Z].*/;
    return obj.type === 'Identifier' && isPascalCaseNameSpace.test(obj.name);
  } else {
    return false;
  }
}

Domain

Subdomains

Calls

Frequently Asked Questions

What does isHook() do?
isHook() is a function in the react codebase, defined in packages/eslint-plugin-react-hooks/src/rules/RulesOfHooks.ts.
Where is isHook() defined?
isHook() is defined in packages/eslint-plugin-react-hooks/src/rules/RulesOfHooks.ts at line 37.
What does isHook() call?
isHook() calls 1 function(s): isHookName.
What calls isHook()?
isHook() is called by 2 function(s): isInsideComponentOrHook, rule.create.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free