I have written a simple react component but it is not rendering the HTML on the page. Could someone please guide me where I am doing wrong?
http://codepen.io/NehhaSharma/pen/EVNdJJ?editors=101
Thanks.
<div id="content"></div>
<script type="text/jsx">
var newComponent = React.createClass({
render : function(){
return (
<h2>My Name is React</h2>
);
}
});
React.render(<newComponent/>,document.getElementById('content'));
</script>
Your component name should start with an upper-case letter. From the React Docs:
To render a React Component, just create a local variable that starts with an upper-case letter:
The following will render as expected:
<div id="content"></div>
<script type="text/jsx">
var NewComponent = React.createClass({
render : function(){
return (
<h2>My Name is React</h2>
);
}
});
React.render(<NewComponent/>,document.getElementById('content'));
</script>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With