mlmorg / react-hyperscript

Hyperscript syntax for React.js markup
MIT License
710 stars 45 forks source link

Problems with parseTag #13

Closed ccorcos closed 8 years ago

ccorcos commented 8 years ago

I'm having some issues understanding the valid format for h's arguments. I keep running into this error:

TypeError: Cannot use 'in' operator to search for 'id' in 10445
    at parseTag (http://localhost:3000/bundle.js:2679:27)
    at h (http://localhost:3000/bundle.js:2652:23)

To reproduce that error, I did:

  const item = (repo) => {
    return (
      h('div.repo', [
        h('div.stars', repo.stargazers_count),
        h('a.name', {href: repo.html_url}, repo.full_name)
      ])
    )
  }

I thought the props were options, but apparently, I have to do this:

  const item = (repo) => {
    return (
      h('div.repo', {}, [
        h('div.stars', {}, repo.stargazers_count),
        h('a.name', {href: repo.html_url}, repo.full_name)
      ])
    )
  }

I thought the properties were optional... ?

mlmorg commented 8 years ago

This is because react-hyperscript looks for a string or an array as a "child" element. In this case, I assume repo.stargazers_count is a number so it is handling it incorrectly. This is a bug in react-hyperscript. I will fix. Just a sec!

mlmorg commented 8 years ago

This has been fixed in v2.2.1. Thanks!

ccorcos commented 8 years ago

thanks dude!