Home / Function/ foo() — react Function Reference

foo() — react Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  c2daa9c8_cb6a_e209_76d4_5afc9ec5a931["foo()"]
  542920e3_4345_faa0_04a3_77849b90b3a4["same-variable-as-dep-and-redeclare-maybe-frozen.js"]
  c2daa9c8_cb6a_e209_76d4_5afc9ec5a931 -->|defined in| 542920e3_4345_faa0_04a3_77849b90b3a4
  style c2daa9c8_cb6a_e209_76d4_5afc9ec5a931 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-maybe-frozen.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 = props.showHeader ? <div>{x}</div> : null;

  // 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-maybe-frozen.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-maybe-frozen.js at line 3.

Analyze Your Own Codebase

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

Try Supermodel Free