Home / Function/ isHook() — react Function Reference

isHook() — react Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  9793c5f8_5898_48eb_13f7_d8191c7098b3["isHook()"]
  9aa4477d_960b_1ea1_b6d9_36076aaa70bd["Program.ts"]
  9793c5f8_5898_48eb_13f7_d8191c7098b3 -->|defined in| 9aa4477d_960b_1ea1_b6d9_36076aaa70bd
  2bfe28c2_c730_2f65_86db_f782c4b5a3e5["getComponentOrHookLike()"]
  2bfe28c2_c730_2f65_86db_f782c4b5a3e5 -->|calls| 9793c5f8_5898_48eb_13f7_d8191c7098b3
  d2202a9e_2022_7233_6674_e1ea8713692c["callsHooksOrCreatesJsx()"]
  d2202a9e_2022_7233_6674_e1ea8713692c -->|calls| 9793c5f8_5898_48eb_13f7_d8191c7098b3
  10c43c7e_c675_98e1_da71_907e0c730975["isHookName()"]
  9793c5f8_5898_48eb_13f7_d8191c7098b3 -->|calls| 10c43c7e_c675_98e1_da71_907e0c730975
  style 9793c5f8_5898_48eb_13f7_d8191c7098b3 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Program.ts lines 1037–1054

function isHook(
  path: NodePath<t.Expression | t.PrivateName>,
  hookPattern: string | null,
): boolean {
  if (path.isIdentifier()) {
    return isHookName(path.node.name, hookPattern);
  } else if (
    path.isMemberExpression() &&
    !path.node.computed &&
    isHook(path.get('property'), hookPattern)
  ) {
    const obj = path.get('object').node;
    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 compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Program.ts.
Where is isHook() defined?
isHook() is defined in compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Program.ts at line 1037.
What does isHook() call?
isHook() calls 1 function(s): isHookName.
What calls isHook()?
isHook() is called by 2 function(s): callsHooksOrCreatesJsx, getComponentOrHookLike.

Analyze Your Own Codebase

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

Try Supermodel Free