Home / Function/ isHook() — react Function Reference

isHook() — react Function Reference

Architecture documentation for the isHook() function in babel-plugin-annotate-react-code.ts from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  4280acf5_f565_fbf1_6a6e_06da2024d5cf["isHook()"]
  90fd4a4d_9742_70a7_9512_f9dd5b565200["babel-plugin-annotate-react-code.ts"]
  4280acf5_f565_fbf1_6a6e_06da2024d5cf -->|defined in| 90fd4a4d_9742_70a7_9512_f9dd5b565200
  40539f87_cad8_e5ab_baf5_c8916ae353cf["isComponentOrHookLike()"]
  40539f87_cad8_e5ab_baf5_c8916ae353cf -->|calls| 4280acf5_f565_fbf1_6a6e_06da2024d5cf
  91675464_ecf7_5d45_b9ac_a40f0b6d6c65["callsHooksOrCreatesJsx()"]
  91675464_ecf7_5d45_b9ac_a40f0b6d6c65 -->|calls| 4280acf5_f565_fbf1_6a6e_06da2024d5cf
  50aa01bd_0e95_3b19_6676_c9060f4d5221["isHookName()"]
  4280acf5_f565_fbf1_6a6e_06da2024d5cf -->|calls| 50aa01bd_0e95_3b19_6676_c9060f4d5221
  style 4280acf5_f565_fbf1_6a6e_06da2024d5cf fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

compiler/packages/babel-plugin-react-compiler/scripts/babel-plugin-annotate-react-code.ts lines 148–162

function isHook(path: NodePath<t.Expression | t.PrivateName>): boolean {
  if (path.isIdentifier()) {
    return isHookName(path.node.name);
  } else if (
    path.isMemberExpression() &&
    !path.node.computed &&
    isHook(path.get('property'))
  ) {
    const obj = path.get('object').node;
    const isPascalCaseNameSpace = /^[A-Z].*/;
    return obj.type === 'Identifier' && isPascalCaseNameSpace.test(obj.name);
  } else {
    return false;
  }
}

Subdomains

Calls

Frequently Asked Questions

What does isHook() do?
isHook() is a function in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/scripts/babel-plugin-annotate-react-code.ts.
Where is isHook() defined?
isHook() is defined in compiler/packages/babel-plugin-react-compiler/scripts/babel-plugin-annotate-react-code.ts at line 148.
What does isHook() call?
isHook() calls 1 function(s): isHookName.
What calls isHook()?
isHook() is called by 2 function(s): callsHooksOrCreatesJsx, isComponentOrHookLike.

Analyze Your Own Codebase

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

Try Supermodel Free