With React Router, any component that uses a part of the react-router-dom
library (like Route
, Link
, Navlink
, etc.) needs to have access to a Router
component. Since the BrowserRouter
(which is a type of Router
) lives in the index.js
file something like this:
// index.js
import { BrowserRouter } from 'react-router-dom';