Skip to content

Instantly share code, notes, and snippets.

@VPAbraham
VPAbraham / react-router-intro.md
Last active October 19, 2019 21:59
react-router-intro

React Router quick start

Install into React project by running

npm install react-router-dom

in App, import:

import { BrowserRouter as Router, Switch, Route} from 'react-router-dom'

you can rename longer import by the example of 'BrowserRouter' above.

Creating a React App

  1. In the terminal run npx create-react-app NAMEOFYOURAPP
  2. Cd into the new directory: cd NAMEOFYOURAPP
  3. Run npm install.
  4. You can run npm start to see if the app was set up correctly.

Setting Up Testing

  1. Install enzyme: npm i enzyme -D
  2. Install enzyme-adapter-react-16: npm install enzyme-adapter-react-16 -D