Home / Function/ Component() — react Function Reference

Component() — react Function Reference

Architecture documentation for the Component() function in useCallback-nonescaping-invoked-callback-escaping-return.js from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  5d373d58_17e1_f6a6_86d1_72ac97830cbe["Component()"]
  f427af30_5f0e_c70f_8dd3_067b47321a27["useCallback-nonescaping-invoked-callback-escaping-return.js"]
  5d373d58_17e1_f6a6_86d1_72ac97830cbe -->|defined in| f427af30_5f0e_c70f_8dd3_067b47321a27
  style 5d373d58_17e1_f6a6_86d1_72ac97830cbe fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/preserve-memo-validation/useCallback-nonescaping-invoked-callback-escaping-return.js lines 4–18

function Component({entity, children}) {
  const showMessage = useCallback(() => entity != null);

  // We currently model functions as if they could escape intor their return value
  // but if we ever changed that (or did optimization to figure out cases where they
  // are known not to) we could get a false positive validation error here, since
  // showMessage doesn't need to be memoized since it doesn't escape in this instance.
  const shouldShowMessage = showMessage();
  return (
    <div>
      <div>{shouldShowMessage}</div>
      <div>{children}</div>
    </div>
  );
}

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/preserve-memo-validation/useCallback-nonescaping-invoked-callback-escaping-return.js.
Where is Component() defined?
Component() is defined in compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/preserve-memo-validation/useCallback-nonescaping-invoked-callback-escaping-return.js at line 4.

Analyze Your Own Codebase

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

Try Supermodel Free