O'Reilly logo

Mastering React by Ryan Vice, Adam Horton

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

JSX

In order to make its component API easier to use, React has its own syntax called JSX, which combines JavaScript and HTML. Let's take a look at updating our sample code to use JSX by copying the following code into hello-react.html and refreshing our browser:

<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8"> <title>Hello React</title> <script src="https://fb.me/react-with-addons-0.14.0.js"></script> <script src="https://fb.me/react-dom-0.14.0.js"></script> <script src="http://fb.me/JSXTransformer-0.13.1.js"></script> </head> <body> <script> var HelloReact = React.createClass({ render: function() { return React.DOM.h1(null, 'Hello React'); } }); ReactDOM.render(React.createElement(HelloReact), document.body); </script> </body> </html> ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required