Skip to content

Commit

Permalink
added navbar to router with children elements
Browse files Browse the repository at this point in the history
  • Loading branch information
Ravik-TH committed Feb 10, 2025
1 parent 84b7923 commit 2fc4902
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 14 deletions.
10 changes: 9 additions & 1 deletion frontend/web-app/src/Components/NavBar.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
import React from 'react'
import { Link, Outlet } from 'react-router-dom';

function NavBar() {
return (
<div>NavBar</div>
<div>
<div>
<Link to="/">Home</Link>
<Link to="/about">About</Link>
<Link to="/faq">FAQ</Link>
</div>
<Outlet />
</div>
)
};

Expand Down
33 changes: 20 additions & 13 deletions frontend/web-app/src/Components/Router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import PlantDetailPage from "../Pages/PlantDetailPage";
import AboutPage from "../Pages/AboutPage";
import FaqPage from "../Pages/FaqPage";
import ErrorPage from "../Pages/ErrorPage";
import NavBar from "./NavBar";

const router = createBrowserRouter([
{
Expand All @@ -16,20 +17,26 @@ const router = createBrowserRouter([
},
{
path: '/',
element: <HomePage/>,
element: <NavBar />,
children: [
{
path: '/',
element: <HomePage/>,
},
{
path: '/plant_detail',
element: <PlantDetailPage/>,
},
{
path: '/about',
element: <AboutPage />,
},
{
path: '/faq',
element: <FaqPage />,
}
]
},
{
path: '/plant_detail',
element: <PlantDetailPage/>,
},
{
path: '/about',
element: <AboutPage />,
},
{
path: '/faq',
element: <FaqPage />,
}
]);

function Provider() {
Expand Down

0 comments on commit 2fc4902

Please sign in to comment.