Ad

React Element Does Not Render

- 1 answer

I have been trying to render a simple element using React. For some reason, very similar examples do work, but my code just can't get working. I can't see any errors, can you please advise me?

    <!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <title>Hello React</title>
    <script src="https://fb.me/react-0.14.6.js"></script>
    <script src="https://fb.me/react-dom-0.14.6.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.23/browser.min.js"></script>
  </head>
  <body>
    <div id="example"></div>
    <script type="text/babel">

    var ExampleElement = React.createClass({

        render : function() { return (<p>P</p>); };

    });

    React.render(<ExampleElement/>, document.getElementById('example'));

    </script>
  </body>
</html>
Ad

Answer

Remove ; after

render : function() { return (<p>P</p>); };
                                          ^^

Also instead of React.render use ReactDOM.render

Example

Ad
source: stackoverflow.com
Ad