I’m trying to use react-router-dom(6.2.1) to transition from one component to another, but it is breaking the application when I try to build it. The code below is the piece that is stopping the application from building. Thanks
@Orly_MUGWANEZA I don’t think it is required to use Router (BrowserRouter) and Switch at the same time, either. I think you can also remove <Router> </Router> since you are using <Switch></Switch> (or viceversa) and if you remove <Router> then you no longer need to import {BrowserRouter as Router}
react-router-dom v6 has a bit different implementation from the one you used (I’m guessing v5 , see here).
The changes affecting your code are the Switch component is replaced with Routes
and the Route prop component is now element. Also as @Gassim suggested, the import should be BrowserRouter as Router.
import React from 'react';
import { BrowserRouter as Router, Route, Routes } from 'react-router-dom';
import Details from './components/Details';
import EntityTable from './components/EntityTable';
const AppRouter = () => (
<Router>
<Routes>
<Route exact path="/" element={<EntityTable/>} />
<Route path="/details" element={<Details/>} />
</Routes>
</Router >
);
export default AppRouter