Reputation: 193
<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.
Upvotes: 3
Views: 175
Reputation: 7408
<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 />
.
Upvotes: 1
Reputation: 77482
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
)Upvotes: 2