Skip to content

Commit

Permalink
inline
Browse files Browse the repository at this point in the history
  • Loading branch information
juliusmarminge committed Feb 11, 2025
1 parent a2f0e50 commit 93af147
Showing 1 changed file with 33 additions and 2 deletions.
35 changes: 33 additions & 2 deletions src/pages/post/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type { NextPageWithLayout } from '~/pages/_app';
import type { RouterOutput } from '~/utils/trpc';
import { useTRPC } from '~/utils/trpc';

import { useQuery } from "@tanstack/react-query";
import { useQuery } from '@tanstack/react-query';

type PostByIdOutput = RouterOutput['post']['byId'];

Expand Down Expand Up @@ -35,7 +35,38 @@ function PostItem(props: { post: PostByIdOutput }) {
const PostViewPage: NextPageWithLayout = () => {
const trpc = useTRPC();
const id = useRouter().query.id as string;
const postQuery = useQuery(trpc.post.byId.queryOptions({ id }));
const opts = trpc.post.byId.queryOptions({ id });
/*
const opts: UnusedSkipTokenTRPCQueryOptionsOut<{
id: string;
title: string;
text: string;
createdAt: Date;
updatedAt: Date;
}, {
id: string;
title: string;
text: string;
createdAt: Date;
updatedAt: Date;
}, TRPCClientErrorLike<{
transformer: true;
errorShape: DefaultErrorShape;
}>>
*/
const postQuery = useQuery(opts);
/**
(alias) useQuery<coerceAsyncIterableToArray<TQueryFnData>, TRPCClientErrorLike<{
transformer: true;
errorShape: DefaultErrorShape;
}>, coerceAsyncIterableToArray<TOutput>, TRPCQueryKey>(options: UndefinedInitialDataOptions<...>, queryClient?: QueryClient): UseQueryResult<...> (+2 overloads)
import useQuery
const postQuery: UseQueryResult<coerceAsyncIterableToArray<TOutput>, TRPCClientErrorLike<{
transformer: true;
errorShape: DefaultErrorShape;
}>>
*/

if (postQuery.error) {
return (
Expand Down

0 comments on commit 93af147

Please sign in to comment.