Open History to see the last commit
1import * as React from 'react'
2import { Link, Outlet, createLazyRoute } from '@tanstack/react-router'
3β
4export const Route = createLazyRoute('/posts')({
5 component: PostsLayoutComponent,
6})
7β
8function PostsLayoutComponent() {
9 const posts = Route.useLoaderData()
10β
11 return (
12 <div className="p-2 flex gap-2">
13 <ul className="list-disc pl-4">
14 {[...posts, { id: 'i-do-not-exist', title: 'Non-existent Post' }].map(
15 (post) => {
16 return (
17 <li key={post.id} className="whitespace-nowrap">
18 <Link
19 to="/posts/$postId"
20 params={{
21 postId: post.id,
22 }}
23 className="block py-1 px-2 text-blue-600 hover:opacity-75"
24 activeProps={{ className: 'font-bold underline' }}
25 >
26 <div>{post.title.substring(0, 20)}</div>
27 </Link>
28 </li>
29 )
30 },
31 )}
32 </ul>
33 <Outlet />
34 </div>
35 )
36}