I am trying to display two different navbar component one as the main site navbar and one for the dashboard navbar.
I have tried creating two reusable components namely:
<LayoutNav />
and <DashboardNav />
Here is their implementation:
const LayoutNav = ({children}) => {
return (
<>
<section className="container-fluid">
<Navbar />
{children}
</section>
</>
);
}
it is the same for LayoutDashboardNav
i only changed <Navbar />
to <DashboardNav />
below is my route implementation:
<BrowserRouter>
<Switch>
<LayoutNav>
<Route exact path="/registervehicle" component={RegVehicle} />
<Route exact path="/result" component={SearchResults} />
<Route exact path="/selectseat" component={PickSeat} />
<Route exact path="/forgotpassword" component={ForgotPassword} />
<Route exact path="/resetpassword" component={ResetPassword} />
<Route exact path="/register" component={Registration} />
<Route exact path="/login" component={LoginAuth} />
<Route exact path="/" component={Home} />
</LayoutNav>
<LayoutDashboardNav>
<Route exact path="/companydashboard" component={CompanyDashboard} />
</LayoutDashboardNav>
<Route component={NotFound} />
</Switch>
<Footer />
</BrowserRouter>
I expect to see <Navbar />
or <DashboardNav />
only on those pages that are children of the components they are used in. But everything is showing only <Navbar />
.