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

Function findFirstJSXText

packages/cli/src/transform.ts:1485–1495  ·  view source on GitHub ↗

* Find the first JSXText node in an AST subtree.

(node: any)

Source from the content-addressed store, hash-verified

1483 * Find the first JSXText node in an AST subtree.
1484 */
1485function findFirstJSXText(node: any): any | null {
1486 if (!node.children) return null;
1487 for (const child of node.children) {
1488 if (child.type === "JSXText" && child.value.trim()) return child;
1489 if (child.type === "JSXElement") {
1490 const found = findFirstJSXText(child);
1491 if (found) return found;
1492 }
1493 }
1494 return null;
1495}
1496
1497/**
1498 * Insert text at a character offset within the concatenated JSXText of a subtree.

Callers 1

mutateTextContentFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected