Home / Function/ foo() — react Function Reference

foo() — react Function Reference

Architecture documentation for the foo() function in same-variable-as-dep-and-redeclare.js from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  92d0cdae_96d8_159c_64f4_54d94a9c3112["foo()"]
  3aa09c46_95a6_eb82_eb04_9164fb9ece99["same-variable-as-dep-and-redeclare.js"]
  92d0cdae_96d8_159c_64f4_54d94a9c3112 -->|defined in| 3aa09c46_95a6_eb82_eb04_9164fb9ece99
  style 92d0cdae_96d8_159c_64f4_54d94a9c3112 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/same-variable-as-dep-and-redeclare.js lines 3–35

function foo(props) {
  // scope 0: deps=[props.a] decl=[x] reassign=none
  let x = [];
  x.push(props.a);

  // scope 1: deps=[x] decl=[header] reassign=none
  const header = <div>{x}</div>;

  // scope 2:
  // deps=[x, props.b, props.c]
  // decl=none
  // reassign=[x]
  const y = [x]; // y depends on the earlier x
  x = []; // x reassigned
  y.push(props.b); // interleaved mutation of x/y
  x.push(props.c); // interleaved mutation

  // scope 3 ...
  const content = (
    <div>
      {x}
      {y}
    </div>
  );

  // scope 4 ...
  return (
    <>
      {header}
      {content}
    </>
  );
}

Subdomains

Frequently Asked Questions

What does foo() do?
foo() is a function in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/same-variable-as-dep-and-redeclare.js.
Where is foo() defined?
foo() is defined in compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/same-variable-as-dep-and-redeclare.js at line 3.

Analyze Your Own Codebase

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

Try Supermodel Free