I am trying to build some routes using react router v5 and basically I have a layout(Dashboard and this dashboard has some routes.) so if I do '/dashboard' it doesn't work'. the '/dashboard' comes from the routes that I map at the last piece of code, which is basically inside the AppContent which is the layout not sure what I am missing here...
my App.js file
<Router>
<Switch>
<Route
exact
path="/"
name="Home"
render={(props) => <DefaultLayout {...props} />}
/>
<Route
path="/login"
name="Login Page"
render={(props) => <Login {...props} />}
/>
<Route
path="/register"
name="Register Page"
render={(props) => <Register {...props} />}
/>
<Route
path="*"
name="Page 404"
render={(props) => <Page404 {...props} />}
/>
</Switch>
</Router>
my DefaultLayout File:
<div>
<AppSidebar />
<div className="wrapper d-flex flex-column min-vh-100 bg-light">
<AppHeader />
<div className="body flex-grow-1 px-3">
<AppContent />
</div>
{/* <AppFooter /> */}
</div>
</div>
my AppContentFile:
<Router>
<Switch>
{routes.map(
(route) =>
route.component && (
<Route
key={route.name}
path={route.path}
exact={route.exact}
name={route.name}
render={(props) => (
<route.component {...props} />
)}
/>
)
)}
<Redirect to="/" />
</Switch>
</Router>