Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Precompiled JSX React,js is not working

Hi I am working through the React.js tutorials and I ran into a snag. When using React it works fine with the jsx transformer on my page. Once I remove that script and compile the jsx to js it no longer works. I'm using the jsx compiler that React recommends on their page. Here's my code:

jsFiddle

<div id="content"></div>
<script src="https://fb.me/react-0.13.1.js"></script>
<script type="text/jsx">
    var CommentBox = React.createClass({displayName: "CommentBox",
        render: function() {
            return (
                    React.createElement("div", {className: "commentBox"},
                            "Hello, world! I am a CommentBox."
                    )
            );
        }
    });
    React.render(
            React.createElement(CommentBox, null),
            document.getElementById('content')
    );
</script>

Thanks for the help!

like image 322
Munk Avatar asked Jul 11 '26 17:07

Munk


1 Answers

<script type="text/jsx">

If you don’t use JSX, you should remove that type. Then it will work as expected. (Fiddle)

like image 164
poke Avatar answered Jul 14 '26 07:07

poke