Imported and tried to use the Switch as in the following;

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

class App extends React.Component  { 
  ...
  ...

  render() {
    return (
      ....
      <Switch>
        <Route exact ...>
      <Switch>
      ....
    )
  }
}

But it threw the error mentioned in the title. Looks like the project has some breaking changes starting from v6.x

So, either you update <Switch /> elements to <Routes />, for details have a look this link, or you can just rollback the react-router-dom version to the latest v5 which currently is v5.3.0:

npm install [email protected]