MCPcopy Create free account
hub / github.com/donghaxkim/react-rewrite / getRenderedChildText

Function getRenderedChildText

packages/cli/src/transform.ts:789–799  ·  view source on GitHub ↗
(child: any, source?: string, lineStarts?: number[])

Source from the content-addressed store, hash-verified

787}
788
789function getRenderedChildText(child: any, source?: string, lineStarts?: number[]): string {
790 if (child.type === "JSXText") return collapseRenderedWhitespace(child.value);
791 if (child.type === "JSXElement") return getRenderedElementText(child, source, lineStarts);
792 if (child.type === "JSXExpressionContainer") {
793 const expr = child.expression;
794 if (expr?.type === "StringLiteral" || expr?.type === "Literal") {
795 return collapseRenderedWhitespace(String(expr.value ?? ""));
796 }
797 }
798 return "";
799}
800
801function needsBoundarySpace(previousText: string, nextText: string, sourceBetween: string): boolean {
802 if (!previousText || !nextText) return false;

Callers 7

getRenderedElementTextFunction · 0.85
hasVisibleTextChildFunction · 0.85
hasVisibleTextInEntriesFunction · 0.85

Calls 2

getRenderedElementTextFunction · 0.85

Tested by

no test coverage detected