The BrowserRouter Component - KatyaHorton/Udacity-React-practice GitHub Wiki
1. Install React Router:
- install react router DOM (as we are in the DOM we will use the DOM package)
npm install --save react-router-dom
-
<BrowserRouter />
listens to changes in the URL - when changes happen - makes sure the right screen shows up
2. Import the component to index.js
import { BrowserRouter } from 'react-router-dom'
3. Wrap entire App
in the BrowserRouter
- sets up the Router to be able to work with all the other components we are going to be importing next
- listens to the URL and notifies those components that the URL changes
ReactDOM.render(
<BrowserRouter><App /></BrowserRouter>,
document.getElementById('root')
)