Home / Function/ Component() — react Function Reference

Component() — react Function Reference

Architecture documentation for the Component() function in error.invalid-referencing-frozen-hoisted-storecontext-const.js from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  14dc8c77_955c_a8cb_f8e3_6e94ffb68aba["Component()"]
  72f80a49_6b81_c4a3_fc4b_983d9110f46d["error.invalid-referencing-frozen-hoisted-storecontext-const.js"]
  14dc8c77_955c_a8cb_f8e3_6e94ffb68aba -->|defined in| 72f80a49_6b81_c4a3_fc4b_983d9110f46d
  style 14dc8c77_955c_a8cb_f8e3_6e94ffb68aba fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/new-mutability/error.invalid-referencing-frozen-hoisted-storecontext-const.js lines 6–22

function Component({content, refetch}) {
  // This callback function accesses a hoisted const as a dependency,
  // but it cannot reference it as a dependency since that would be a
  // TDZ violation!
  const onRefetch = useCallback(() => {
    refetch(data);
  }, [refetch]);

  // The context variable gets frozen here since it's passed to a hook
  const onSubmit = useIdentity(onRefetch);

  // This has to error: onRefetch needs to memoize with `content` as a
  // dependency, but the dependency comes later
  const {data = null} = content;

  return <Foo data={data} onSubmit={onSubmit} />;
}

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/new-mutability/error.invalid-referencing-frozen-hoisted-storecontext-const.js.
Where is Component() defined?
Component() is defined in compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/new-mutability/error.invalid-referencing-frozen-hoisted-storecontext-const.js at line 6.

Analyze Your Own Codebase

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

Try Supermodel Free