Home / Function/ useFoo() — react Function Reference

useFoo() — react Function Reference

Architecture documentation for the useFoo() function in nested-optional-chains.ts from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  acc1bcc0_c65a_1256_5752_e17a30658eca["useFoo()"]
  eeb934fb_296b_0e55_b05b_f663aa600ad7["nested-optional-chains.ts"]
  acc1bcc0_c65a_1256_5752_e17a30658eca -->|defined in| eeb934fb_296b_0e55_b05b_f663aa600ad7
  style acc1bcc0_c65a_1256_5752_e17a30658eca fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/nested-optional-chains.ts lines 8–35

function useFoo({
  prop1,
  prop2,
  prop3,
  prop4,
  prop5,
  prop6,
}: {
  prop1: null | {value: number};
  prop2: null | {inner: {value: number}};
  prop3: null | {fn: (val: any) => NonNullable<object>};
  prop4: null | {inner: {value: number}};
  prop5: null | {fn: (val: any) => NonNullable<object>};
  prop6: null | {inner: {value: number}};
}) {
  // prop1?.value should be hoisted as the dependency of x
  const x = identity(prop1?.value)?.toString();

  // prop2?.inner.value should be hoisted as the dependency of y
  const y = identity(prop2?.inner.value)?.toString();

  // prop3 and prop4?.inner should be hoisted as the dependency of z
  const z = prop3?.fn(prop4?.inner.value).toString();

  // prop5 and prop6?.inner should be hoisted as the dependency of zz
  const zz = prop5?.fn(prop6?.inner.value)?.toString();
  return [x, y, z, zz];
}

Subdomains

Frequently Asked Questions

What does useFoo() do?
useFoo() is a function in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/nested-optional-chains.ts.
Where is useFoo() defined?
useFoo() is defined in compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/nested-optional-chains.ts at line 8.

Analyze Your Own Codebase

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

Try Supermodel Free