Implementing React Router v4
React, unlike Angular, is a library instead of a framework, meaning specific functionalities, for example, routing or the propTypes, are not part of the React core. Instead, routing is handled by a third-party library called React Router.
Getting ready
We will use the code that we did in theImplementing Airbnb React/JSX Style Guide recipe in Chapter 3, Handling Events, Binding, and Useful React Packages (Repository:Chapter03/Recipe4/airbnb) to enable linter validation.
The first thing we need to do is to install React Router v4, and we can do it with this command:
npm install react-router-domYou probably are confused about why we are installing react-router-dom instead of react-router. React Router contains all the common components of react-router-dom and react-router-native. That means that if you are using React for the web, you should use react-router-dom, and if you are using React Native, you need to use react-router-native. The react-router-dompackage was...