Home / Function/ Component() — react Function Reference

Component() — react Function Reference

Architecture documentation for the Component() function in repro-no-declarations-in-reactive-scope-with-early-return.js from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  ad54c845_8c6a_91d9_0eae_3ee3b9a1d9c7["Component()"]
  c1d777b9_cde5_60a6_59c7_4519a29e78b9["repro-no-declarations-in-reactive-scope-with-early-return.js"]
  ad54c845_8c6a_91d9_0eae_3ee3b9a1d9c7 -->|defined in| c1d777b9_cde5_60a6_59c7_4519a29e78b9
  style ad54c845_8c6a_91d9_0eae_3ee3b9a1d9c7 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/repro-no-declarations-in-reactive-scope-with-early-return.js lines 2–29

function Component() {
  const items = useItems();
  const filteredItems = useMemo(
    () =>
      items.filter(([item]) => {
        return item.name != null;
      }),
    [item]
  );

  if (filteredItems.length === 0) {
    // note: this must return nested JSX to create the right scope
    // shape that causes no declarations to be emitted
    return (
      <div>
        <span />
      </div>
    );
  }

  return (
    <>
      {filteredItems.map(([item]) => (
        <Stringify item={item} />
      ))}
    </>
  );
}

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/repro-no-declarations-in-reactive-scope-with-early-return.js.
Where is Component() defined?
Component() is defined in compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/repro-no-declarations-in-reactive-scope-with-early-return.js at line 2.

Analyze Your Own Codebase

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

Try Supermodel Free