I am trying to set up a new project in Visual Studio, which will be MVC 5 with a one-page application written in ReactJS. So I followed the tutorial on the ReactJS website .
I got to the first part where you run the project, and I received a syntax error due to JSX (the browser seems to want to interpret it as vanilla JavaScript, which makes sense). So I added type="text/jsx"a script to the tag.
In general, my HTML / JSX looks like this:
HTML output using the Razor view
<!doctype html>
<html>
<head>
<title>Hello React</title>
</head>
<body>
<div id="content"></div>
<script src="http://fb.me/react-0.12.2.js"></script>
<script type="text/jsx" src="/Scripts/Tutorial.jsx"></script>
</body>
</html>
Tutorial.jsx
var CommentBox = React.createClass({
render: function() {
return (
<div className="comment-box">
Hello, world! I am a CommentBox.
</div>
);
}
});
React.render(
<CommentBox />,
document.getElementById('content')
);
- ? , type="text/jsx" script. , - , JSX JS, , , .
Chrome Developer Tools.