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

Function getStaticRenderableText

packages/cli/src/batch-transform.ts:705–725  ·  view source on GitHub ↗
(node: any)

Source from the content-addressed store, hash-verified

703}
704
705function getStaticRenderableText(node: any): string | null {
706 if (!node) return "";
707 if (node.type === "JSXText") return collapseVisibleWhitespace(node.value ?? "");
708 if (node.type === "JSXElement") {
709 const parts: string[] = [];
710 for (const child of node.children ?? []) {
711 const text = getStaticRenderableText(child);
712 if (text == null) return null;
713 parts.push(text);
714 }
715 return collapseVisibleWhitespace(parts.join(""));
716 }
717 if (node.type === "JSXExpressionContainer") {
718 const expr = node.expression;
719 if (expr?.type === "StringLiteral" || expr?.type === "Literal") {
720 return collapseVisibleWhitespace(String(expr.value ?? ""));
721 }
722 return null;
723 }
724 return "";
725}
726
727function readStringLiteralValue(node: any): string | null {
728 if (!node) return null;

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected