Creating a container React component
Let's start by editing our application's main JavaScript file. Replace the content of the ~/snapterest/source/app.js
file with the following code snippet:
import React from 'react'; import ReactDOM from 'react-dom'; import Application from './components/Application'; ReactDOM.render( <Application />, document.getElementById('react-application') );
There are only four lines of code in this file, and as you can guess, they provide document.getElementById('react-application')
as a deployment target for the <Application/>
component and render <Application/>
to the DOM. The whole user interface for our web application will be encapsulated in one React component, Application
.
Next, navigate to ~/snapterest/source/components/ ...
Get React 16 Essentials - Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.