Home / Function/ createNewFunctionNode() — react Function Reference

createNewFunctionNode() — react Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  1e86a202_a347_7857_88d3_50b0dc42a045["createNewFunctionNode()"]
  9aa4477d_960b_1ea1_b6d9_36076aaa70bd["Program.ts"]
  1e86a202_a347_7857_88d3_50b0dc42a045 -->|defined in| 9aa4477d_960b_1ea1_b6d9_36076aaa70bd
  ade5f434_a213_5611_b4fa_0fdd254474e1["insertNewOutlinedFunctionNode()"]
  ade5f434_a213_5611_b4fa_0fdd254474e1 -->|calls| 1e86a202_a347_7857_88d3_50b0dc42a045
  11c511ca_2971_a23f_cfd6_2897f2fe1b13["applyCompiledFunctions()"]
  11c511ca_2971_a23f_cfd6_2897f2fe1b13 -->|calls| 1e86a202_a347_7857_88d3_50b0dc42a045
  d7fde76c_4fd9_feb3_299b_798689f05bc6["assertExhaustive()"]
  1e86a202_a347_7857_88d3_50b0dc42a045 -->|calls| d7fde76c_4fd9_feb3_299b_798689f05bc6
  style 1e86a202_a347_7857_88d3_50b0dc42a045 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Program.ts lines 224–281

export function createNewFunctionNode(
  originalFn: BabelFn,
  compiledFn: CodegenFunction,
): t.FunctionDeclaration | t.ArrowFunctionExpression | t.FunctionExpression {
  let transformedFn:
    | t.FunctionDeclaration
    | t.ArrowFunctionExpression
    | t.FunctionExpression;
  switch (originalFn.node.type) {
    case 'FunctionDeclaration': {
      const fn: t.FunctionDeclaration = {
        type: 'FunctionDeclaration',
        id: compiledFn.id,
        loc: originalFn.node.loc ?? null,
        async: compiledFn.async,
        generator: compiledFn.generator,
        params: compiledFn.params,
        body: compiledFn.body,
      };
      transformedFn = fn;
      break;
    }
    case 'ArrowFunctionExpression': {
      const fn: t.ArrowFunctionExpression = {
        type: 'ArrowFunctionExpression',
        loc: originalFn.node.loc ?? null,
        async: compiledFn.async,
        generator: compiledFn.generator,
        params: compiledFn.params,
        expression: originalFn.node.expression,
        body: compiledFn.body,
      };
      transformedFn = fn;
      break;
    }
    case 'FunctionExpression': {
      const fn: t.FunctionExpression = {
        type: 'FunctionExpression',
        id: compiledFn.id,
        loc: originalFn.node.loc ?? null,
        async: compiledFn.async,
        generator: compiledFn.generator,
        params: compiledFn.params,
        body: compiledFn.body,
      };
      transformedFn = fn;
      break;
    }
    default: {
      assertExhaustive(
        originalFn.node,
        `Creating unhandled function: ${originalFn.node}`,
      );
    }
  }
  // Avoid visiting the new transformed version
  return transformedFn;
}

Domain

Subdomains

Frequently Asked Questions

What does createNewFunctionNode() do?
createNewFunctionNode() is a function in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Program.ts.
Where is createNewFunctionNode() defined?
createNewFunctionNode() is defined in compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Program.ts at line 224.
What does createNewFunctionNode() call?
createNewFunctionNode() calls 1 function(s): assertExhaustive.
What calls createNewFunctionNode()?
createNewFunctionNode() is called by 2 function(s): applyCompiledFunctions, insertNewOutlinedFunctionNode.

Analyze Your Own Codebase

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

Try Supermodel Free