1

I fail to understand why the following would not render a button on the page:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>Basic Example</title>    
  </head>
  <body>

    <div id="container"></div>

    <script src="./build/react.js"></script>
    <script src="./build/react-dom.js"></script>
    <script src="./build/react-with-addons.js"></script>



<script type="text/jsx">
      /** @jsx React.DOM */

var Button = React.createClass({
  render: function(){
    return (
      <button>Go</button>
      )
  }
});

ReactDOM.render(<Button />, document.getElementById('container'));

 </script>  


  </body>
</html>

The only output i see in the console is:

Download the React DevTools for a better development experience: https://fb.me/react-devtools

As I understand this is not an error message.

3
  • You are trying to render the same component you declaring. Also try to dont name your components as html existing ones. Commented Dec 9, 2015 at 0:02
  • does not help solve my issue Commented Dec 9, 2015 at 0:10
  • Hi, I am new to react and am getting the same error while running a simple 'Hello world' example. Is your query resolved ? Please update this page with answer that worked for you. Thanks a lot. Commented Nov 2, 2016 at 11:48

1 Answer 1

3

These are the minimal changes I found to make it work. (See also the Getting Started page.)

  • Replace ./build/react-with-addons.js with https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.23/browser.min.js.
  • Replace text/jsx with text/babel.
  • Delete the line /** @jsx React.DOM */.

But this can cause other error messages, at least in Firefox, in the console, although this doesn't affect the functionality of the example.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.