Switch was not found in 'react-router-dom' 1

Switch was not found in ‘react-router-dom’

import React from "react";
import { BrowserRouter as Router, Route, Routes } from "react-router-dom";

//------------------------------------------------IMPORTS VIEWS-----------------------------------------------
import Home from "./views/Home.js";
//------------------------------------------------CLASS APP-----------------------------------------------
class App extends React.Component {
  constructor(props) {

  render() {
    return (
          } />

export default App;

Here is what the above code is Doing:
1. We’re importing the Router, Route, and Routes components from react-router-dom.
2. We’re importing the Home component from the views folder.
3. We’re creating a class called App that extends the React.Component class.
4. We’re creating a constructor that takes in props and calls super(props).
5. We’re creating a render method that returns a Router component.
6. We’re creating a Routes component that contains a Route component.
7. We’re creating a Route component that has an exact path of “/” and an element of .
8. We’re exporting the App class.

Now that we have our App component, let’s create our Home component.

Create a file called Home.js in the views folder and add the following code:

Similar Posts