switch is not exported from 'react-router-dom' 1

switch is not exported from ‘react-router-dom’

npm install react-router-dom@5.2.0

Here is what the above code is Doing:
1. We’re importing the BrowserRouter component from the react-router-dom library.
2. We’re importing the Route component from the react-router-dom library.
3. We’re importing the Switch component from the react-router-dom library.
4. We’re importing the Link component from the react-router-dom library.
5. We’re importing the Home component from the ./Home.js file.
6. We’re importing the About component from the ./About.js file.
7. We’re importing the Contact component from the ./Contact.js file.
8. We’re importing the NotFound component from the ./NotFound.js file.
9. We’re creating a new BrowserRouter component and passing it the following props:
– basename: “/react-router-demo”
– children: A Switch component with the following props:
– children: An array of Route components with the following props:
– path: “/”
– exact: true
– component: Home
– path: “/about”
– component: About
– path: “/contact”
– component: Contact
– component: NotFound
10. We’re exporting the BrowserRouter component.

Similar Posts