Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

changed to createBrowserRouter #205

Merged
merged 1 commit into from
Apr 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 20 additions & 17 deletions frontend/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,30 @@
import { BrowserRouter,Route,Routes } from "react-router-dom";
import { Header } from "./components/Header/Header";
import { Route,RouterProvider, createBrowserRouter, createRoutesFromElements } from "react-router-dom";
import Layout from "./components/Header/Layout";
import Home from "./pages/home/Home";
import LanguagePath from "./components/LanguagePath";
import ProjectView from "./pages/project/projectView/ProjectView";

const router = createBrowserRouter(
createRoutesFromElements(
<Route path="/" element={<Layout />}>
<Route index element={<Home />} />
<Route path=":lang" element={<LanguagePath/>}>
<Route path="home" element={<Home />} />
<Route path="project" >
<Route path=":projectId" element={<ProjectView />}/>
</Route>
</Route>
</Route>
)
);

/**
* This component is the main application component that will be rendered by the ReactDOM.
* @returns - The main application component
*/
function App(): JSX.Element {
export default function App(): React.JSX.Element {
return (
<BrowserRouter>
<Header />
<Routes>
<Route index element={<Home />} />
<Route path=":lang" element={<LanguagePath/>}>
<Route path="home" element={<Home />} />
<Route path="project" >
<Route path=":projectId" element={<ProjectView />}/>
</Route>
</Route>
</Routes>
</BrowserRouter>
<RouterProvider router={router}>
</RouterProvider>
);
}
export default App;
}
15 changes: 15 additions & 0 deletions frontend/src/components/Header/Layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Outlet } from "react-router-dom";
import { Header } from "./Header.tsx";

/**
* Basic layout component that will be used on all routes.
* @returns The Layout component
*/
export default function Layout(): JSX.Element {
return (
<>
<Header />
<Outlet />
</>
);
}