Skip to content

Commit

Permalink
fix: use layout as a parent element
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielborgesdm committed May 24, 2024
1 parent 3854115 commit 5a1a7c0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
9 changes: 3 additions & 6 deletions frontend/src/components/Layout.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import { Outlet } from "react-router-dom";
import { Navbar } from "./Navbar/Navbar";

interface LayoutProps {
element: React.ReactNode;
}

const Layout: React.FC<LayoutProps> = ({ element }) => (
const Layout: React.FC = () => (
<>
<Navbar />
{element}
<Outlet />
</>
);

Expand Down
21 changes: 14 additions & 7 deletions frontend/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,27 @@ import {
} from "react-router-dom";

import Books from 'pages/Books/Books';
import './index.css';
import { Navbar } from 'components/Navbar/Navbar';
import Authors from 'pages/Authors/Authors';
import Layout from 'components/Layout';

import './index.css';

const router = createBrowserRouter([
{
path: "/",
element: <Layout element={<Books />} />,
},
{
path: "/authors",
element: <Layout element={<Authors />} />,
element: <Layout />,
children: [
{
path: "",
element: <Books />,
},
{
path: "authors",
element: <Authors />,
},
]
},

]);

const root = ReactDOM.createRoot(
Expand Down

0 comments on commit 5a1a7c0

Please sign in to comment.