codecret | Software EngineerC
tRPC7mo ago
4 replies
codecret | Software Engineer

can I use useUtils hook in trpc 11 ?

export const usePublicBlogs = () => {
  const trpc = useTRPC();
  return trpc.blogs.getPublicBlogs.queryOptions();
};

  const { data: blogPosts, isLoading, error } = usePublicBlogs();


this is my trpc query, trpc query dont provide data, isLoading or error
Property 'data' does not exist on type 'UnusedSkipTokenTRPCQueryOptionsOut<{ id: string; title: string; content: string; excerpt: string | null; author: string; category: string; readTime: string; status: string; isFeatured: boolean; image: string | null; createdAt: Date; updatedAt: Date; }[], { ...; }[], TRPCClientErrorLike<...>>'.ts(2339)


also i want to invalidate my queries for example invalidate fetching posts query when doing a mutation (IN THE NEW WAY)
 await utils.blogs.getBlogs.invalidate();

Property 'invalidate' does not exist on type 'DecorateQueryProcedure<{ input: void; output: { id: string; title: string; content: string; excerpt: string | null; author: string; category: string; readTime: string; status: string; isFeatured: boolean; image: string | null; createdAt: Date; updatedAt: Date; }[]; transformer: true; errorShape: DefaultErrorShape; }...'.ts(2339)
Was this page helpful?