I am struggling with a problem i cant seem to find an answer to. As soon as I am adding a div or any other Component inside the Route it is not rendering the the content and the containing "Application" anymore. I hope I described my Problem enough and you guys know an easy solution.
import React from 'react';
import "./App.css"
import { BrowserRouter, Route, Routes } from 'react-router-dom';
function App() {
return (
<div className="wrapper">
<h1>Application</h1>
<BrowserRouter>
<Routes>
<Route path="/dashboard">
<div>hi dashboard</div>
</Route>
<Route path="/preferences">
<div>hi preferences</div>
</Route>
</Routes>
</BrowserRouter>
</div>
);
}
export default App;
The Route component expects an element prop.
Try this
<BrowserRouter>
<Routes>
<Route path="/dashboard" element={<div>hi dashboard</div>} />
<Route path="/preferences" element={<div>hi preferences</div>} />
</Routes>
</BrowserRouter>