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

$postId-component.tsx

18 lines518 Bytes

1import * as React from 'react'
2import { useLoaderData, useMatch } from '@tanstack/react-router'
3import { routeConfig } from '../../routes.generated/posts/$postId'
4export type PostType = {
5 id: string
6 title: string
7 body: string
8}
9function Post() {
10 const { post } = useLoaderData({ from: routeConfig.id })
11 return (
12 <div className="space-y-2">
13 <h4 className="text-xl font-bold underline">{post.title}</h4>
14 <div className="text-sm">{post.body}</div>
15 </div>
16 )
18export const component = Post