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

Function wrappedComponentName

src/resolution/frameworks/react.ts:898–907  ·  view source on GitHub ↗
(component: Node, context: ResolutionContext)

Source from the content-addressed store, hash-verified

896 * around an inline render function, which has a body of its own.
897 */
898export function wrappedComponentName(component: Node, context: ResolutionContext): string | null {
899 const code = stripCommentsForRegex(declarationText(component, context), 'typescript');
900 const init = initializerAt(code, component.name.length);
901 if (init < 0) return null;
902 const expression = code.slice(init, statementEnd(code, init)).trim();
903 const styled = /^styled\s*\(\s*([A-Za-z_$][\w$]*)\s*[,)]/.exec(expression);
904 const name = styled ? styled[1]!
905 : /^(?:React\s*\.\s*)?(?:memo|forwardRef)\b/.test(expression) ? wrappedName(expression) : null;
906 return name && isPascalCase(name) && name !== component.name ? name : null;
907}
908
909/**
910 * The component a route's `layout:` reference names, found the way the

Callers 1

reactJsxChildEdgesFunction · 0.90

Calls 7

stripCommentsForRegexFunction · 0.90
initializerAtFunction · 0.85
wrappedNameFunction · 0.85
declarationTextFunction · 0.70
statementEndFunction · 0.70
isPascalCaseFunction · 0.70
execMethod · 0.65

Tested by

no test coverage detected