Home / Function/ defaultModuleTypeProvider() — react Function Reference

defaultModuleTypeProvider() — react Function Reference

Architecture documentation for the defaultModuleTypeProvider() function in DefaultModuleTypeProvider.ts from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  6204b19c_6449_a980_1bf5_f89bdc7ea490["defaultModuleTypeProvider()"]
  0c7e53f1_4ebc_f3be_54f8_05e81729a4e9["DefaultModuleTypeProvider.ts"]
  6204b19c_6449_a980_1bf5_f89bdc7ea490 -->|defined in| 0c7e53f1_4ebc_f3be_54f8_05e81729a4e9
  style 6204b19c_6449_a980_1bf5_f89bdc7ea490 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

compiler/packages/babel-plugin-react-compiler/src/HIR/DefaultModuleTypeProvider.ts lines 42–109

export function defaultModuleTypeProvider(
  moduleName: string,
): TypeConfig | null {
  switch (moduleName) {
    case 'react-hook-form': {
      return {
        kind: 'object',
        properties: {
          useForm: {
            kind: 'hook',
            returnType: {
              kind: 'object',
              properties: {
                // Only the `watch()` function returned by react-hook-form's `useForm()` API is incompatible
                watch: {
                  kind: 'function',
                  positionalParams: [],
                  restParam: Effect.Read,
                  calleeEffect: Effect.Read,
                  returnType: {kind: 'type', name: 'Any'},
                  returnValueKind: ValueKind.Mutable,
                  knownIncompatible: `React Hook Form's \`useForm()\` API returns a \`watch()\` function which cannot be memoized safely.`,
                },
              },
            },
          },
        },
      };
    }
    case '@tanstack/react-table': {
      return {
        kind: 'object',
        properties: {
          /*
           * Many of the properties of `useReactTable()`'s return value are incompatible, so we mark the entire hook
           * as incompatible
           */
          useReactTable: {
            kind: 'hook',
            positionalParams: [],
            restParam: Effect.Read,
            returnType: {kind: 'type', name: 'Any'},
            knownIncompatible: `TanStack Table's \`useReactTable()\` API returns functions that cannot be memoized safely`,
          },
        },
      };
    }
    case '@tanstack/react-virtual': {
      return {
        kind: 'object',
        properties: {
          /*
           * Many of the properties of `useVirtualizer()`'s return value are incompatible, so we mark the entire hook
           * as incompatible
           */
          useVirtualizer: {
            kind: 'hook',
            positionalParams: [],
            restParam: Effect.Read,
            returnType: {kind: 'type', name: 'Any'},
            knownIncompatible: `TanStack Virtual's \`useVirtualizer()\` API returns functions that cannot be memoized safely`,
          },
        },
      };
    }
  }
  return null;
}

Subdomains

Frequently Asked Questions

What does defaultModuleTypeProvider() do?
defaultModuleTypeProvider() is a function in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/src/HIR/DefaultModuleTypeProvider.ts.
Where is defaultModuleTypeProvider() defined?
defaultModuleTypeProvider() is defined in compiler/packages/babel-plugin-react-compiler/src/HIR/DefaultModuleTypeProvider.ts at line 42.

Analyze Your Own Codebase

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

Try Supermodel Free