Open History to see the last commit
1import { lazy } from '@tanstack/react-router'
2import { routeConfig as parentRouteConfig } from './__root'
3import * as React from 'react'
4import { Link, Outlet, useLoaderData, useMatch } from '@tanstack/react-router'
5import { postspostIdRoute } from '../routes.generated/posts/$postId.client'
6const routeConfig = parentRouteConfig.createRoute({
7 path: 'posts',
8 component: Posts,
9 loader: (...args) =>
10 import('./posts-loader').then((d) => d.loader.apply(d.loader, args as any)),
11 errorComponent: () => 'Oh crap',
12})
13function Posts() {
14 const { posts } = useLoaderData({ from: routeConfig.id })
15 return (
16 <div className="p-2 flex gap-2">
17 <ul className="list-disc pl-4">
18 {posts?.map((post) => {
19 return (
20 <li key={post.id} className="whitespace-nowrap">
21 <Link
22 to={postspostIdRoute.id}
23 params={{
24 postId: post.id,
25 }}
26 className="block py-1 text-blue-800 hover:text-blue-600"
27 activeProps={{
28 className: 'text-black font-bold',
29 }}
30 >
31 <div>{post.title.substring(0, 20)}</div>
32 </Link>
33 </li>
34 )
35 })}
36 </ul>
37 <hr />
38 <Outlet />
39 </div>
40 )
41}
42export { routeConfig }