0

Uncaught SyntaxError: The requested module '/node_modules/.vite/deps/react-router-dom.js?v=63986831' does not provide an export named 'Switch'

My components are not rendering. This is my second project and in first project I used CRA to create react app and now I used vite . I installed react router dom still it it thorws error saying . I am totally new to this .Thanks for your time.

import { Switch } from "react-router-dom";
import { Route } from "react-router-dom";
import Login from './login.jsx'
import Home from "./component/home/Home.jsx"
import './index.css'

const App = () => {
  return (
    <>
      <Switch>
        <Route path='/' component={Home} />
        <Route path="/login" component={Login} />
      </Switch>
    </>
  );

} export default App;

Robin Dhami
  • 11
  • 1
  • 3
  • `Switch` doesn't exist anymore. Check the [upgrade guide](https://reactrouter.com/en/main/upgrading/v5#upgrade-all-switch-elements-to-routes), you need to use `Routes` now. – Zac Anger Apr 29 '23 at 05:09
  • If you are wanting to use the `Switch` component then install the correct version, e.g. `npm i -S react-router-dom@5`, otherwise complete the [upgrade from v5 to v6](https://reactrouter.com/en/main/upgrading/v5). – Drew Reese Apr 29 '23 at 05:32

0 Answers0