Home / Function/ Component() — react Function Reference

Component() — react Function Reference

Architecture documentation for the Component() function in error.todo-for-loop-with-context-variable-iterator.js from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  b7c65cd6_80cf_d546_1c50_3d8019bdb5d7["Component()"]
  b77240f4_0743_7e16_de34_e57b25e9f488["error.todo-for-loop-with-context-variable-iterator.js"]
  b7c65cd6_80cf_d546_1c50_3d8019bdb5d7 -->|defined in| b77240f4_0743_7e16_de34_e57b25e9f488
  style b7c65cd6_80cf_d546_1c50_3d8019bdb5d7 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.todo-for-loop-with-context-variable-iterator.js lines 3–24

function Component() {
  const data = useIdentity(
    new Map([
      [0, 'value0'],
      [1, 'value1'],
    ])
  );
  const items = [];
  // NOTE: `i` is a context variable because it's reassigned and also referenced
  // within a closure, the `onClick` handler of each item
  // TODO: for loops create a unique environment on each iteration, which means
  // that if the iteration variable is only updated in the updater, the variable
  // is effectively const within the body and the "update" acts more like
  // a re-initialization than a reassignment.
  // Until we model this "new environment" semantic, we allow this case to error
  for (let i = MIN; i <= MAX; i += INCREMENT) {
    items.push(
      <Stringify key={i} onClick={() => data.get(i)} shouldInvokeFns={true} />
    );
  }
  return <>{items}</>;
}

Subdomains

Frequently Asked Questions

What does Component() do?
Component() is a function in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.todo-for-loop-with-context-variable-iterator.js.
Where is Component() defined?
Component() is defined in compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.todo-for-loop-with-context-variable-iterator.js at line 3.

Analyze Your Own Codebase

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

Try Supermodel Free