Open History to see the last commit
1import { createFileRoute } from '@tanstack/react-router'
2import { useQuery } from '@tanstack/react-query'
3import { trpc } from '../router'
4β
5export const Route = createFileRoute('/dashboard/')({
6 loader: async ({ context: { trpc, queryClient } }) => {
7 await queryClient.ensureQueryData(trpc.posts.queryOptions())
8 return
9 },
10 component: DashboardIndexComponent,
11})
12β
13function DashboardIndexComponent() {
14 const postsQuery = useQuery(trpc.posts.queryOptions())
15β
16 const posts = postsQuery.data || []
17β
18 return (
19 <div className="p-2">
20 <div className="p-2">
21 Welcome to the dashboard! You have{' '}
22 <strong>{posts.length} total posts</strong>.
23 </div>
24 </div>
25 )
26}