Even though I used Routes instead of switch still its showing the same error ,I installed react dom using the command npm install -S react-router-dom. The code is below
import './App.css';
import Header from './Header';
import Home from './Home';
import {BrowserRouter as Router,Switch,Route} from 'react-router-dom';
function App() {
return (
> <Router>
> <div className='app'>
> <Switch>
> <Route path='/'>
> <Header/>
> <Home/>
> </Route>
> </Switch>
> </div>
> </Router>
export default App;
The Error that is showing is 'Switch' (imported as 'Switch') was not found in 'react-router-dom' And 'Route' (imported as 'Route') was not found in 'react-router-dom'
CodePudding user response:
I assume that you are using react router v5 as switch is is not in v6. In that case the import for switch is following:
import { Switch } from "react-router";
You are importing it from react-router-dom
while it should be from react-router
CodePudding user response:
read documentation of react-router-dom v6