Home / Function/ Component() — react Function Reference

Component() — react Function Reference

Architecture documentation for the Component() function in error.invalid-mutate-context-in-callback.js from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  db3b2225_c00d_b430_6c62_0fc88195932d["Component()"]
  26595230_63d8_1322_be52_4ce6cee98395["error.invalid-mutate-context-in-callback.js"]
  db3b2225_c00d_b430_6c62_0fc88195932d -->|defined in| 26595230_63d8_1322_be52_4ce6cee98395
  style db3b2225_c00d_b430_6c62_0fc88195932d fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.invalid-mutate-context-in-callback.js lines 1–15

function Component(props) {
  const FooContext = useContext(Foo);
  // This function should be memoized, but its mutable range is entangled
  // with the useContext call. We can't memoize hooks, therefore the
  // reactive scope around the hook + callback is pruned and we're left
  // w no memoization of the callback.
  //
  // Ideally we'd determine that this isn't called during render and can
  // therefore be considered "immutable" or otherwise safe to memoize
  // independently
  const onClick = () => {
    FooContext.current = true;
  };
  return <div onClick={onClick} />;
}

Domain

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

Analyze Your Own Codebase

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

Try Supermodel Free