Home / Function/ Component() — react Function Reference

Component() — react Function Reference

Architecture documentation for the Component() function in error.invalid-mutate-global-in-render-helper-phi-return-prop.js from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  6524bff7_2289_99b5_6dc6_5c8ef29e8699["Component()"]
  b6b51249_bebc_3c32_62df_0bfbe4d0dcc4["error.invalid-mutate-global-in-render-helper-phi-return-prop.js"]
  6524bff7_2289_99b5_6dc6_5c8ef29e8699 -->|defined in| b6b51249_bebc_3c32_62df_0bfbe4d0dcc4
  style 6524bff7_2289_99b5_6dc6_5c8ef29e8699 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.invalid-mutate-global-in-render-helper-phi-return-prop.js lines 1–16

function Component() {
  const renderItem = item => {
    // Multiple returns so that the return type is a Phi (union)
    if (item == null) {
      return null;
    }
    // Normally we assume that it's safe to mutate globals in a function passed
    // as a prop, because the prop could be used as an event handler or effect.
    // But if the function returns JSX we can assume it's a render helper, ie
    // called during render, and thus it's unsafe to mutate globals or call
    // other impure code.
    global.property = true;
    return <Item item={item} value={rand} />;
  };
  return <ItemList renderItem={renderItem} />;
}

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.invalid-mutate-global-in-render-helper-phi-return-prop.js.
Where is Component() defined?
Component() is defined in compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.invalid-mutate-global-in-render-helper-phi-return-prop.js at line 1.

Analyze Your Own Codebase

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

Try Supermodel Free