moroshko / react-scanner

Extract React components and props usage from code.
MIT License
563 stars 40 forks source link

Unknown node type: JSXSpreadChild #70

Open yakunins opened 10 months ago

yakunins commented 10 months ago

To support JSX spread child and to avoid such a error in scan.js:

Error: Unknown node type: JSXSpreadChild
    at getPropValue (C:\ServiceTitan\playground\DesignSystem\react-scanner\node_modules\react-scanner\src\scan.js:48:9)
    at getInstanceInfo (C:\ServiceTitan\playground\DesignSystem\react-scanner\node_modules\react-scanner\src\scan.js:82:11)
    at Object.exit (C:\ServiceTitan\playground\DesignSystem\react-scanner\node_modules\react-scanner\src\scan.js:221:22)

please replace https://github.com/moroshko/react-scanner/blob/8290a229b7818e06a053a8d4ea519eaa0c909a13/src/scan.js#L39 with

  if (node.type === "JSXExpressionContainer" || node.type === "JSXSpreadChild") {