mlmorg / react-hyperscript

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

When child component is react component invoke React.createElement() when necessary #6

Closed andrewdeandrade closed 9 years ago

andrewdeandrade commented 9 years ago

Assuming a react component called Foo;

The current code needs to be:

  render: function() {
    return h('div', {
      className: 'some-class'
    }, React.createElement(Foo, { propA: 'some value' }));

Ideally, this shouldn't be necessary and you should be able to do just:

  render: function() {
    return h('div', {
      className: 'some-class'
    }, Foo({ propA: 'some value' }));

ref: https://gist.github.com/sebmarkbage/ae327f2eda03bf165261

mlmorg commented 9 years ago

You can do this with:

return h('div', {className: 'some-class'}, [
  h(Foo, {propA: 'some value' })
]);
mlmorg commented 9 years ago

Going to close but reopen if I'm misunderstanding your question

andrewdeandrade commented 9 years ago

No, that solves the problem. merci