MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / declaredComponent

Function declaredComponent

src/resolution/frameworks/react.ts:685–698  ·  view source on GitHub ↗
(
  name: string,
  filePath: string,
  context: ResolutionContext,
)

Source from the content-addressed store, hash-verified

683 * such value (a function or class component is found the usual way).
684 */
685export function declaredComponent(
686 name: string,
687 filePath: string,
688 context: ResolutionContext,
689): { declaration: Node; component: Node | null } | undefined {
690 const declaration = declaredValue(name, filePath, context);
691 if (!declaration) return undefined;
692 const loaded = valueLoader(declaration, context);
693 if (!loaded) return { declaration, component: wrappedComponent(declaration, context) };
694 const id = loaded.member === 'default'
695 ? lazyRouteComponent(loaded.spec, filePath, context)
696 : pickedExport(loaded.spec, loaded.member, filePath, context);
697 return { declaration, component: id ? context.getNodeById?.(id) ?? null : null };
698}
699
700/**
701 * The module a value `filePath` declares as `name` loads lazily, and the

Callers 3

ownValueOfFunction · 0.90
resolveFunction · 0.85
layoutComponentFunction · 0.85

Calls 6

declaredValueFunction · 0.85
valueLoaderFunction · 0.85
wrappedComponentFunction · 0.85
lazyRouteComponentFunction · 0.85
pickedExportFunction · 0.85
getNodeByIdMethod · 0.65

Tested by

no test coverage detected