1

This is, i believe, a real basic problem. Therefore i don't know why it doesn't work. I have React and React DOM installed through NPM. Here's the HTML:

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv='Content-type' content='text/html; charset=utf-8'>
        <title>Basic Example</title>
    </head>
    <body>
        <div id="container" style="height:200px;">
            <p>Test</p>
        </div>   
    </body>
    <script type="test/jsx" src="main.js"></script>
</html>

and here's the JS:

var React = require('react');
var ReactDOM = require('react-dom');

var Hello = React.createClass({
  render: function() {
    return <div>Hello {this.props.name}</div>;
  }
});

ReactDOM.render(
  <Hello name="World" />,
  document.getElementById('container')
);

I'm supposed to see a Hello World but only get a Test inside, thus meanings nothing is changed inside my div#container

1 Answer 1

3

You need to transpile the jsx code. Look at this tutorial for a hint. http://facebook.github.io/react/docs/tutorial.html

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.