shay te
shay te

Reputation: 1068

React render an empty component

i am using react in ES5 syntax, but i a getting a weird behavior

TestCom = React.createClass( {render: function() {return React.createElement('div', null, ['asdasd']) }} )

ReactDOM.render(React.createElement('TestCom', {}), document.getElementById('matches'));

will output

<testcomp data-reactroot=""></testcomp>

what am i missing ?

thank you

Upvotes: 0

Views: 124

Answers (1)

Clarity
Clarity

Reputation: 10873

You need to pass the component itself, not its name:

ReactDOM.render(React.createElement(TestCom, {}), document.getElementById('matches'));

Upvotes: 1

Related Questions