Open History to see the last commit
1import { lazy } from '@tanstack/react-router'
2import { routeConfig as parentRouteConfig } from '../posts'
3import * as React from 'react'
4import { useLoaderData, useMatch } from '@tanstack/react-router'
5export type PostType = {
6 id: string
7 title: string
8 body: string
9}
10const routeConfig = parentRouteConfig.createRoute({
11 path: '$postId',
12 component: Post,
13 loader: (...args) =>
14 import('./$postId-loader').then((d) =>
15 d.loader.apply(d.loader, args as any),
16 ),
17})
18function Post() {
19 const { post } = useLoaderData({ from: routeConfig.id })
20 return (
21 <div className="space-y-2">
22 <h4 className="text-xl font-bold underline">{post.title}</h4>
23 <div className="text-sm">{post.body}</div>
24 </div>
25 )
26}
27export { routeConfig }