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

Function handedComponent

src/resolution/frameworks/react.ts:879–886  ·  view source on GitHub ↗

* The component of its own file a wrapper call around a declaration hands * over: `const TableView = observer(TableViewInner)`, or mastodon's `const * MemoizedBlurhash = memo(Blurhash)`, whose component node has no body of its * own to render from.

(value: Node, context: ResolutionContext, nodes = context.getNodesInFile(value.filePath))

Source from the content-addressed store, hash-verified

877 * own to render from.
878 */
879function handedComponent(value: Node, context: ResolutionContext, nodes = context.getNodesInFile(value.filePath)): Node | null {
880 const code = stripCommentsForRegex(declarationText(value, context), 'typescript');
881 const init = initializerAt(code, value.name.length);
882 const handed = init < 0 ? null : wrappedName(code.slice(init, statementEnd(code, init)));
883 return handed && isPascalCase(handed) && handed !== value.name
884 ? nodes.find((n) => n.name === handed && n.qualifiedName === handed && COMPONENT_KINDS.has(n.kind)) ?? null
885 : null;
886}
887
888/**
889 * The name of the component a wrapper component's declaration hands its

Callers 2

exportedComponentFunction · 0.85
wrappedComponentFunction · 0.85

Calls 8

stripCommentsForRegexFunction · 0.90
initializerAtFunction · 0.85
wrappedNameFunction · 0.85
hasMethod · 0.80
declarationTextFunction · 0.70
statementEndFunction · 0.70
isPascalCaseFunction · 0.70
getNodesInFileMethod · 0.65

Tested by

no test coverage detected