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

posts_.$postId.deep.tsx

26 lines751 Bytes

1import { Link, createFileRoute } from '@tanstack/react-router'
2import { fetchPost } from '../utils/posts'
3import { PostErrorComponent } from './posts.$postId'
4​
5export const Route = createFileRoute('/posts_/$postId/deep')({
6 loader: async ({ params: { postId } }) => fetchPost(postId),
7 errorComponent: PostErrorComponent,
8 component: PostDeepComponent,
9})
10​
11function PostDeepComponent() {
12 const post = Route.useLoaderData()
13​
14 return (
15 <div className="p-2 space-y-2">
16 <Link
17 to="/posts"
18 className="block py-1 text-blue-800 hover:text-blue-600"
19 >
20 ← All Posts
21 </Link>
22 <h4 className="text-xl font-bold underline">{post.title}</h4>
23 <div className="text-sm">{post.body}</div>
24 </div>
25 )