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

Function getJSXId

packages/cli/src/batch-transform.ts:172–181  ·  view source on GitHub ↗

Get the id attribute from a JSX element.

(node: any)

Source from the content-addressed store, hash-verified

170
171/** Get the id attribute from a JSX element. */
172function getJSXId(node: any): string | null {
173 const attrs = node.openingElement?.attributes ?? [];
174 const idAttr = attrs.find(
175 (a: any) => a.type === "JSXAttribute" && a.name?.name === "id"
176 );
177 if (!idAttr?.value) return null;
178 const val = idAttr.value;
179 if (val.type === "StringLiteral" || val.type === "Literal") return val.value;
180 return null;
181}
182
183/** Get the key prop from a JSX element. */
184function getJSXKey(node: any): string | null {

Callers 1

resolveNodesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected