MCPcopy Create free account
hub / github.com/QodeXcli/QodeX / detectReactComponent

Function detectReactComponent

src/artifacts/preview.ts:92–98  ·  view source on GitHub ↗
(src: string)

Source from the content-addressed store, hash-verified

90
91/** Best-effort: find the root React component name to mount (defaults to "App"). */
92export function detectReactComponent(src: string): string {
93 const m =
94 src.match(/function\s+([A-Z][A-Za-z0-9_]*)\s*\(/) ||
95 src.match(/(?:const|let|var)\s+([A-Z][A-Za-z0-9_]*)\s*=\s*(?:\(|function|React\.memo|memo)/) ||
96 src.match(/class\s+([A-Z][A-Za-z0-9_]*)\s+extends/);
97 return m ? m[1] : 'App';
98}
99
100function reactHarness(src: string): string {
101 const code = stripModuleSyntax(src);

Callers 2

reactHarnessFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected