Home / Function/ callsHooksOrCreatesJsx() — react Function Reference

callsHooksOrCreatesJsx() — react Function Reference

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

Entity Profile

Dependency Diagram

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

Relationship Graph

Source Code

compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Program.ts lines 1231–1256

function callsHooksOrCreatesJsx(
  node: NodePath<
    t.FunctionDeclaration | t.ArrowFunctionExpression | t.FunctionExpression
  >,
  hookPattern: string | null,
): boolean {
  let invokesHooks = false;
  let createsJsx = false;

  node.traverse({
    JSX() {
      createsJsx = true;
    },
    CallExpression(call) {
      const callee = call.get('callee');
      if (callee.isExpression() && isHook(callee, hookPattern)) {
        invokesHooks = true;
      }
    },
    ArrowFunctionExpression: skipNestedFunctions(node),
    FunctionExpression: skipNestedFunctions(node),
    FunctionDeclaration: skipNestedFunctions(node),
  });

  return invokesHooks || createsJsx;
}

Domain

Subdomains

Frequently Asked Questions

What does callsHooksOrCreatesJsx() do?
callsHooksOrCreatesJsx() is a function in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Program.ts.
Where is callsHooksOrCreatesJsx() defined?
callsHooksOrCreatesJsx() is defined in compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Program.ts at line 1231.
What does callsHooksOrCreatesJsx() call?
callsHooksOrCreatesJsx() calls 2 function(s): isHook, skipNestedFunctions.
What calls callsHooksOrCreatesJsx()?
callsHooksOrCreatesJsx() is called by 1 function(s): getComponentOrHookLike.

Analyze Your Own Codebase

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

Try Supermodel Free