44 lines
1.3 KiB
TypeScript
Raw Normal View History

2023-11-03 12:06:55 +03:00
import { Routes, Route, Outlet } from "react-router-dom";
import Home from "./pages/Home";
import About from "./pages/About";
import Dashboard from "./pages/Dashboard";
import NoMatch from "./pages/NoMatch";
import NavBar from "./components/NavBar";
export default function App() {
2023-10-28 19:56:16 +03:00
return (
2023-11-03 12:06:55 +03:00
<div>
<h1>Basic Example</h1>
{/* Routes nest inside one another. Nested route paths build upon
parent route paths, and nested route elements render inside
parent route elements. See the note about <Outlet> below. */}
<Routes>
<Route path="/" element={<Layout />}>
<Route index element={<Home />} />
<Route path="about" element={<About />} />
<Route path="dashboard" element={<Dashboard />} />
{/* Using path="*"" means "match anything", so this route
acts like a catch-all for URLs that we don't have explicit
routes for. */}
<Route path="*" element={<NoMatch />} />
</Route>
</Routes>
</div>
);
}
2023-10-28 19:56:16 +03:00
2023-11-03 12:06:55 +03:00
function Layout() {
return (
<div>
<NavBar/>
2023-10-29 20:19:59 +02:00
2023-11-03 12:06:55 +03:00
{/* An <Outlet> renders whatever child route is currently active,
so you can think about this <Outlet> as a placeholder for
the child routes we defined above. */}
<Outlet />
2023-10-28 19:56:16 +03:00
</div>
);
}