<body>
<div id="content"></div>
<script type="text/jsx">
var x = React.createClass({
render:function(){
return (
<h1>I love react</h1>
);
}
});
React.render(<x/>,document.getElementById('content'));
</script>
</body>
What's wrong with my reactjs code below? it render nothing. I've included
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.14.6/react.min.js"></script>
in the head.
You have several mistakes
ReactDOM and use ReactDOM.render, because since version 0.14.* .render method that located in React is deprecated.X not x)type="text/jsx" you should use type="text/babel" (don't forget include babel)Example
<script type="text/jsx"> won't work. This was how old versions did using the old jsx transformer but it's now deprecated.
Use babel instead. Read more about this topic here.
Also your components' names should always start with a capital letter. <X /> not <x />.
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