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
  61f6a131_5e62_c325_40b6_07b8fc888f38["useFoo()"]
  58e5a3b5_0138_e51d_189a_5e27b7b2e45e["nested-optional-chains.ts"]
  61f6a131_5e62_c325_40b6_07b8fc888f38 -->|defined in| 58e5a3b5_0138_e51d_189a_5e27b7b2e45e
  style 61f6a131_5e62_c325_40b6_07b8fc888f38 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/propagate-scope-deps-hir-fork/nested-optional-chains.ts lines 10–37

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/propagate-scope-deps-hir-fork/nested-optional-chains.ts.
Where is useFoo() defined?
useFoo() is defined in compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/propagate-scope-deps-hir-fork/nested-optional-chains.ts at line 10.

Analyze Your Own Codebase

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

Try Supermodel Free