Hello I'm trying to do multiple routes with the react router, but without success basically i have a layout that will have different content and also a dashboard with different contents, but without success
const HomeContent = () => {
return (
<div style={{ background: 'red', width: '100%', height: '400px' }}>
Home
</div>
);
};
const AboutContent = () => {
return (
<div style={{ background: 'blue', width: '100%', height: '400px' }}>
About
</div>
);
};
const DashBoardNav = () => {
return (
<div style={{ background: 'red', width: '100%', height: '400px' }}>
DashBoardNav
<ul>
<li>Home</li>
<li>About</li>
</ul>
</div>
);
};
const MainRoutes = () => {
const dispatch = useDispatch();
const { popUpIsOpen } = useSelector(RootState => RootState.togglePopUp);
const { sideIsOpen } = useSelector(RootState => RootState.toggleSide);
return (
<GlobalContainer>
<GlobalStyle />
<Overlay
onClick={() =>
popUpIsOpen ? dispatch(toggle()) : dispatch(toggleSide())
}
pop={popUpIsOpen ? popUpIsOpen : sideIsOpen}
/>
<Routes>
<Route path="/" element={<Header />} />
<Route path="dashboard" element={<DashBoardNav />} />
</Routes>
<Content>
<Routes>
<Route exact path="/" element={<HomeContent />}>
<Route path="about" element={<AboutContent />} />
</Route>
<Route path="dashboard" element={<> DashBoard </>}>
<Route path="about" element={<> about </>} />
</Route>
</Routes>
</Content>
<Footer />
</GlobalContainer>
);
};
export default MainRoutes;
But I am getting the following error my navbar renders normal in my "/", and my Home component like this:
And when I try to enter my "/ about" path, my navbar does not appear and my div ABOUT (component: AboutContent) neither:
Basically I need multiple routes
where I have two navbars (one is from the lading page and others, and one from the dashboard)
equally with the content