Looking for example of layout usage #456
Answered
by
Moshyfawn
netanelben
asked this question in
Q&A
Replies: 1 comment
-
import { createRouteConfig, Outlet, createReactRouter } from '@tanstack/react-router'
const rootRoute = createRouteConfig()
const layoutRoute = rootRoute.createRoute({
id: "layout",
component: () => (
<div>
<header>...</header>
<main>
<Outlet />
</main>
<footer>...</footer>
</div>
),
});
const indexRoute = layoutRoute.createRoute({
path: '/'
})
const fooRoute = layoutRoute.createRoute({
path: 'foo'
})
const routeConfig = rootRoute.addChildren([layoutRoute.addChildren([fooRoute, indexRoute])])
const router = createReactRouter({
routeConfig
}) |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
netanelben
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Im looking for an react best practice example of using the layout mechanism of the router, for the most basic website usage which is rendering Header and Footer components and in between the route match components.
So the header + footer would be the common logic for each route.
Appreciate any help,
thanks in advance.
Beta Was this translation helpful? Give feedback.
All reactions