Skip to content
Source
Sign inSign up
TanStack/router
Open History to see the last commit

SharedNestedLayout.tsx

29 lines933 Bytes

1import { Link, linkOptions } from '@tanstack/react-router'
2import type { ReactNode } from 'react'
3import styles from '~/styles/shared-layout.module.css'
4​
5const SHARED_ROUTES = linkOptions([
6 { to: '/shared-a', label: '/shared-a' },
7 { to: '/shared-b', label: '/shared-b' },
8 { to: '/shared-c', label: '/shared-c' },
9])
10​
11export function SharedNestedLayout({ children }: { children: ReactNode }) {
12 return (
13 <section className={styles.layout} data-testid="shared-layout-shell">
14 <div className={styles.heading} data-testid="shared-layout-heading">
15 Shared nested layout CSS module
16 </div>
17 <nav>
18 {SHARED_ROUTES.map((route) => (
19 <Link key={route.to} {...route} data-testid={`nav-${route.label}`}>
20 {route.label}
21 </Link>
22 ))}
23 </nav>
24 <div className={styles.body} data-testid="shared-layout-copy">
25 {children}
26 </div>
27 </section>
28 )