poetic / reacterminator

Convert html to react components in es6 syntax.
56 stars 6 forks source link

fails to convert component with unhelpful error #47

Open cdaringe opened 8 years ago

cdaringe commented 8 years ago

problem statement

discusion

<!-- card.html -->
<div class="bill brasky">
  <h4>card title</h4>
  <p>content</p>
</div>
$ reacterminator c html/card.html
/usr/local/lib/node_modules/reacterminator/lib/plugins/main/process-each-jsx-snippet.js:74
    const isSvg = $node.get(0).tagName === 'svg';
                              ^

TypeError: Cannot read property 'tagName' of undefined
    at traverse (/usr/local/lib/node_modules/reacterminator/lib/plugins/main/process-each-jsx-snippet.js:74:31)
    at traverse (/usr/local/lib/node_modules/reacterminator/lib/helpers/traverse-cheerio-node.js:2:7)
    at replaceAttrNameForJsx (/usr/local/lib/node_modules/reacterminator/lib/plugins/main/process-each-jsx-snippet.js:72:3)
    at processEachJsxSnippet (/usr/local/lib/node_modules/reacterminator/lib/plugins/main/process-each-jsx-snippet.js:105:3)
    at _.reduce (/usr/local/lib/node_modules/reacterminator/lib/index.js:44:12)
    at /usr/local/lib/node_modules/reacterminator/node_modules/lodash/lodash.js:928:11
    at /usr/local/lib/node_modules/reacterminator/node_modules/lodash/lodash.js:4938:15
    at baseForOwn (/usr/local/lib/node_modules/reacterminator/node_modules/lodash/lodash.js:2988:24)
    at /usr/local/lib/node_modules/reacterminator/node_modules/lodash/lodash.js:4907:18
    at baseReduce (/usr/local/lib/node_modules/reacterminator/node_modules/lodash/lodash.js:925:5)
Chun-Yang commented 8 years ago

Hey @cdaringe , right now, you have to wrap your divs into body tags.