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

Function getJSXKey

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

Get the key prop from a JSX element.

(node: any)

Source from the content-addressed store, hash-verified

182
183/** Get the key prop from a JSX element. */
184function getJSXKey(node: any): string | null {
185 const attrs = node.openingElement?.attributes ?? [];
186 const keyAttr = attrs.find(
187 (a: any) => a.type === "JSXAttribute" && a.name?.name === "key"
188 );
189 if (!keyAttr?.value) return null;
190 const val = keyAttr.value;
191 if (val.type === "StringLiteral" || val.type === "Literal") return val.value;
192 return null;
193}
194
195/** Check if AST static classes are a subset of the DOM classes provided. */
196function classNameSubsetMatch(astClasses: string[], domClassName: string): boolean {

Callers 1

resolveNodesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected