in my react app routing is not working and it throws an error in the console. in my index file
import { BrowserRouter as Router, Route } from 'react-router-dom';
<React.StrictMode>
<Router>
<Route path="/" element={<App />} />
</Router>
</React.StrictMode>
and in my App.js
import { Route, Routes, useHistory } from 'react-router-dom';
function App() {
return (
<div className="App">
{/* <DataProvder> */}
<Sidebar />
<Routes>
<Route path='/' element={<Home />} />
<Route path='/students' element={<Students />} />
<Route path='/schools' element={<Schools />} />
<Route path='/campus' element={<Campus />} />
<Route path='/placement' element={<Placement />} />
<Route path='/courses' element={<Courses />} />
<Route path='/staff' element={<Staff />} />
</Routes>
{/* </DataProvder> */}
</div>
);
}
export default App;
When running this there is nothing to display, but in the console it throws this error:
Uncaught Error: A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.
What am I doing wrong here?