Home / Function/ lowerJsxElementName() — react Function Reference

lowerJsxElementName() — react Function Reference

Architecture documentation for the lowerJsxElementName() function in BuildHIR.ts from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  bc571674_9276_a5d1_38b8_101118e7d161["lowerJsxElementName()"]
  e04c04d6_37a7_1dc3_7fae_7d07660d0af9["BuildHIR.ts"]
  bc571674_9276_a5d1_38b8_101118e7d161 -->|defined in| e04c04d6_37a7_1dc3_7fae_7d07660d0af9
  ace1177a_10b2_b870_31fd_da4aa845554c["lowerExpression()"]
  ace1177a_10b2_b870_31fd_da4aa845554c -->|calls| bc571674_9276_a5d1_38b8_101118e7d161
  ed6d70a7_397f_1137_1a2e_8b9092747144["getLoadKind()"]
  bc571674_9276_a5d1_38b8_101118e7d161 -->|calls| ed6d70a7_397f_1137_1a2e_8b9092747144
  f1f0c182_09ad_b29e_b1ca_56f10046adff["lowerValueToTemporary()"]
  bc571674_9276_a5d1_38b8_101118e7d161 -->|calls| f1f0c182_09ad_b29e_b1ca_56f10046adff
  b210ff8f_3273_1b70_4f00_b08cc41fd3dd["lowerIdentifier()"]
  bc571674_9276_a5d1_38b8_101118e7d161 -->|calls| b210ff8f_3273_1b70_4f00_b08cc41fd3dd
  7477f6f4_c8ce_95b3_d35f_2f53341af86d["lowerJsxMemberExpression()"]
  bc571674_9276_a5d1_38b8_101118e7d161 -->|calls| 7477f6f4_c8ce_95b3_d35f_2f53341af86d
  073c81a5_c389_d108_5b8f_4d6dc6eece83["push()"]
  bc571674_9276_a5d1_38b8_101118e7d161 -->|calls| 073c81a5_c389_d108_5b8f_4d6dc6eece83
  style bc571674_9276_a5d1_38b8_101118e7d161 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

compiler/packages/babel-plugin-react-compiler/src/HIR/BuildHIR.ts lines 3246–3304

function lowerJsxElementName(
  builder: HIRBuilder,
  exprPath: NodePath<
    t.JSXIdentifier | t.JSXMemberExpression | t.JSXNamespacedName
  >,
): Place | BuiltinTag {
  const exprNode = exprPath.node;
  const exprLoc = exprNode.loc ?? GeneratedSource;
  if (exprPath.isJSXIdentifier()) {
    const tag: string = exprPath.node.name;
    if (tag.match(/^[A-Z]/)) {
      const kind = getLoadKind(builder, exprPath);
      return lowerValueToTemporary(builder, {
        kind: kind,
        place: lowerIdentifier(builder, exprPath),
        loc: exprLoc,
      });
    } else {
      return {
        kind: 'BuiltinTag',
        name: tag,
        loc: exprLoc,
      };
    }
  } else if (exprPath.isJSXMemberExpression()) {
    return lowerJsxMemberExpression(builder, exprPath);
  } else if (exprPath.isJSXNamespacedName()) {
    const namespace = exprPath.node.namespace.name;
    const name = exprPath.node.name.name;
    const tag = `${namespace}:${name}`;
    if (namespace.indexOf(':') !== -1 || name.indexOf(':') !== -1) {
      builder.errors.push({
        reason: `Expected JSXNamespacedName to have no colons in the namespace or name`,
        description: `Got \`${namespace}\` : \`${name}\``,
        category: ErrorCategory.Syntax,
        loc: exprPath.node.loc ?? null,
        suggestions: null,
      });
    }
    const place = lowerValueToTemporary(builder, {
      kind: 'Primitive',
      value: tag,
      loc: exprLoc,
    });
    return place;
  } else {
    builder.errors.push({
      reason: `(BuildHIR::lowerJsxElementName) Handle ${exprPath.type} tags`,
      category: ErrorCategory.Todo,
      loc: exprPath.node.loc ?? null,
      suggestions: null,
    });
    return lowerValueToTemporary(builder, {
      kind: 'UnsupportedNode',
      node: exprNode,
      loc: exprLoc,
    });
  }
}

Subdomains

Called By

Frequently Asked Questions

What does lowerJsxElementName() do?
lowerJsxElementName() is a function in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/src/HIR/BuildHIR.ts.
Where is lowerJsxElementName() defined?
lowerJsxElementName() is defined in compiler/packages/babel-plugin-react-compiler/src/HIR/BuildHIR.ts at line 3246.
What does lowerJsxElementName() call?
lowerJsxElementName() calls 5 function(s): getLoadKind, lowerIdentifier, lowerJsxMemberExpression, lowerValueToTemporary, push.
What calls lowerJsxElementName()?
lowerJsxElementName() is called by 1 function(s): lowerExpression.

Analyze Your Own Codebase

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

Try Supermodel Free