Skip to content

Looking for example of layout usage #456

Answered by Moshyfawn
netanelben asked this question in Q&A
Discussion options

You must be logged in to vote
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
})

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by netanelben
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants