Home / Function/ nameAnonymousFunctions() — react Function Reference

nameAnonymousFunctions() — react Function Reference

Architecture documentation for the nameAnonymousFunctions() function in NameAnonymousFunctions.ts from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  7dbadf38_2b2d_c297_97fe_6d8f3cf17eaf["nameAnonymousFunctions()"]
  701ffa03_e96c_b2c6_bca0_39530945bc61["NameAnonymousFunctions.ts"]
  7dbadf38_2b2d_c297_97fe_6d8f3cf17eaf -->|defined in| 701ffa03_e96c_b2c6_bca0_39530945bc61
  c3bc3875_256f_8f5e_7800_2f9c5bae65eb["runWithEnvironment()"]
  c3bc3875_256f_8f5e_7800_2f9c5bae65eb -->|calls| 7dbadf38_2b2d_c297_97fe_6d8f3cf17eaf
  1001c7b5_d0e2_33dd_e8da_f3e0f2e25b65["nameAnonymousFunctionsImpl()"]
  7dbadf38_2b2d_c297_97fe_6d8f3cf17eaf -->|calls| 1001c7b5_d0e2_33dd_e8da_f3e0f2e25b65
  style 7dbadf38_2b2d_c297_97fe_6d8f3cf17eaf fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

compiler/packages/babel-plugin-react-compiler/src/Transform/NameAnonymousFunctions.ts lines 15–44

export function nameAnonymousFunctions(fn: HIRFunction): void {
  if (fn.id == null) {
    return;
  }
  const parentName = fn.id;
  const functions = nameAnonymousFunctionsImpl(fn);
  function visit(node: Node, prefix: string): void {
    if (node.generatedName != null && node.fn.nameHint == null) {
      /**
       * Note that we don't generate a name for functions that already had one,
       * so we'll only add the prefix to anonymous functions regardless of
       * nesting depth.
       */
      const name = `${prefix}${node.generatedName}]`;
      node.fn.nameHint = name;
      node.fn.loweredFunc.func.nameHint = name;
    }
    /**
     * Whether or not we generated a name for the function at this node,
     * traverse into its nested functions to assign them names
     */
    const nextPrefix = `${prefix}${node.generatedName ?? node.fn.name ?? '<anonymous>'} > `;
    for (const inner of node.inner) {
      visit(inner, nextPrefix);
    }
  }
  for (const node of functions) {
    visit(node, `${parentName}[`);
  }
}

Domain

Subdomains

Frequently Asked Questions

What does nameAnonymousFunctions() do?
nameAnonymousFunctions() is a function in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/src/Transform/NameAnonymousFunctions.ts.
Where is nameAnonymousFunctions() defined?
nameAnonymousFunctions() is defined in compiler/packages/babel-plugin-react-compiler/src/Transform/NameAnonymousFunctions.ts at line 15.
What does nameAnonymousFunctions() call?
nameAnonymousFunctions() calls 1 function(s): nameAnonymousFunctionsImpl.
What calls nameAnonymousFunctions()?
nameAnonymousFunctions() is called by 1 function(s): runWithEnvironment.

Analyze Your Own Codebase

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

Try Supermodel Free