Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
59 lines (50 sloc) 1.45 KB
<!doctype html>
<title>02 JSX - React From Zero</title>
<script src=""></script>
<script src=""></script>
<script src="">
// Now we will use JSX, which needs to be converted to JavaScript.
// For this we will use Babel. Babel is normally used to convert
// ES2015 to ES5, but it also can convert JSX to ES5. Babels browser
// version uses text/babel script tags.
<div id="app"></div>
<script type="text/babel">
// JSX is the idiomatic way of creating elements.
// It's basically XHTML with {} for dynamic content
// also class has to be called className
var reactElement = (
style={{ textAlign: "center" }}
onClick={function() {
Hello, world!
// Is the same as
reactElement = React.createElement(
className: "abc",
style: { textAlign: "center" },
onClick: function() {
"Hello, world!"
// JSX shines with simple elements that make up the majority
var anotherElement = <p>A nice text paragraph.</p>;
// Is the same as
anotherElement = React.createElement(
"A nice text paragraph."
// As we can see, everything else works as before
var renderTarget = document.getElementById("app");
ReactDOM.render(reactElement, renderTarget);