Home / Function/ Component() — react Function Reference

Component() — react Function Reference

Architecture documentation for the Component() function in aliased-nested-scope-fn-expr.tsx from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  4a7e3572_8a67_6e9a_45f9_3f514eb90c13["Component()"]
  628390ea_abba_ee81_f26d_b104444da189["aliased-nested-scope-fn-expr.tsx"]
  4a7e3572_8a67_6e9a_45f9_3f514eb90c13 -->|defined in| 628390ea_abba_ee81_f26d_b104444da189
  style 4a7e3572_8a67_6e9a_45f9_3f514eb90c13 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/aliased-nested-scope-fn-expr.tsx lines 26–40

function Component({prop}) {
  let obj = shallowCopy(prop);

  const aliasedObj = identity(obj);

  // When `obj` is mutable (either directly or through aliases), taking a
  // dependency on `obj.id` is invalid as it may change before getId() is invoked
  const getId = () => obj.id;

  mutate(aliasedObj);
  setPropertyByKey(aliasedObj, 'id', prop.id + 1);

  // Calling getId() should return prop.id + 1, not the prev
  return <Stringify getId={getId} shouldInvokeFns={true} />;
}

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/aliased-nested-scope-fn-expr.tsx.
Where is Component() defined?
Component() is defined in compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/aliased-nested-scope-fn-expr.tsx at line 26.

Analyze Your Own Codebase

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

Try Supermodel Free