Using React Router 4

Setting up the Development Environment

Setting up the Development Environment

First things first. Let's get all the starter files we need. We will be concentrating on setting up the routes for an application, and, therefore, won't be creating any of the views from scratch. Use Git to pull down the latest code, install the dependencies, and run the dev server.

git clone https://github.com/scotch-io/react-router-course.git
cd react-router-demo
yarn
yarn dev

Now open your browser to http://localhost:3000. You should see a page showing all the users we have in our "database."

When we ran the yarn dev command, an express server was started up. This express server creates an API that gives us a CRUD interface to the users that are defined in the users.json file. This is just dummy data for us to play with. It also starts a webpack development server that will run our webpack build and recompile it every time we update our code. It also enables hot module reloading.

Now that we have our environment set up and we can see it working in the browser, we will add the router and get things displaying through it in the next video.