October 2017
Intermediate to advanced
302 pages
7h 27m
English
Here's a secret about React--it's a library for creating UIs, but not a library for rendering UIs. In itself, it has no mechanism for rendering a UI to the browser.
Fortunately, the creators of React also have a package called ReactDOM for exactly this purpose. Let's install it and then see how it works.
First, we install it with yarn add react-dom@15.6.1.
Then, require it in index.html in much the same way as React:
<body> <img src="assets/icon.png" id="test-image"/> <h1>Hello world!</h1> <div id="root"></div> <script src="../node_modules/react/dist/react.js"></script> <script src="../node_modules/react-dom/dist/react-dom.js"></script> <script> console.log(React.createElement('h1', null, 'Hello from react!')); </script> ...Read now
Unlock full access