"Angular directives on crack."
- Joe Alves
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Hello React</title>
<!-- Loads React -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.14.0/react.js"></script>
<!-- Loads ReactDOM -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.14.0/react-dom.js"></script>
<!-- Loads Babel -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.6.15/browser.js"></script>
</head>
<body>
<div id="content"></div>
<script type="text/babel">
// our React code will go here for now
</script>
</body>
</html>
const App = React.createClass({
render: function () {
return <h1 className="greeting">Hello World!</h1>
}
});
ReactDOM.render(
<App />,
document.getElementById('content')
);
const Worlds = React.createClass({
render: function () {
return (
<ul>
<li>Earth</li>
<li>Krypton</li>
<li>Valhalla</li>
</ul>
);
}
});
const App = React.createClass({
render: function () {
// important: only one parent node
return (
<div>
<h1>Hello world</h1>
<p>Which world are you from</p>
<Worlds />
</div>
);
}
});
ReactDOM.render(
<App />,
document.getElementById('content');
)