Home / Function/ evalStringAndTemplateConcat() — react Function Reference

evalStringAndTemplateConcat() — react Function Reference

Architecture documentation for the evalStringAndTemplateConcat() function in evalToString.js from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  e25c678a_d9c1_58ba_f3f9_0921537586bd["evalStringAndTemplateConcat()"]
  87f81810_3f4f_a028_8989_01251185890b["evalToString.js"]
  e25c678a_d9c1_58ba_f3f9_0921537586bd -->|defined in| 87f81810_3f4f_a028_8989_01251185890b
  style e25c678a_d9c1_58ba_f3f9_0921537586bd fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

scripts/shared/evalToString.js lines 25–54

function evalStringAndTemplateConcat(ast, args) {
  switch (ast.type) {
    case 'StringLiteral':
      return ast.value;
    case 'BinaryExpression': // `+`
      if (ast.operator !== '+') {
        throw new Error('Unsupported binary operator ' + ast.operator);
      }
      return (
        evalStringAndTemplateConcat(ast.left, args) +
        evalStringAndTemplateConcat(ast.right, args)
      );
    case 'TemplateLiteral': {
      let elements = [];
      for (let i = 0; i < ast.quasis.length; i++) {
        const elementNode = ast.quasis[i];
        if (elementNode.type !== 'TemplateElement') {
          throw new Error('Unsupported type ' + ast.type);
        }
        elements.push(elementNode.value.cooked);
      }
      args.push(...ast.expressions);
      return elements.join('%s');
    }
    default:
      // Anything that's not a string is interpreted as an argument.
      args.push(ast);
      return '%s';
  }
}

Domain

Subdomains

Frequently Asked Questions

What does evalStringAndTemplateConcat() do?
evalStringAndTemplateConcat() is a function in the react codebase, defined in scripts/shared/evalToString.js.
Where is evalStringAndTemplateConcat() defined?
evalStringAndTemplateConcat() is defined in scripts/shared/evalToString.js at line 25.

Analyze Your Own Codebase

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

Try Supermodel Free