tRPCttRPC
Powered by
codecret | Software EngineerC
tRPC•8mo 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();
};
export const usePublicBlogs = () => {
  const trpc = useTRPC();
  return trpc.blogs.getPublicBlogs.queryOptions();
};

  const { data: blogPosts, isLoading, error } = usePublicBlogs();
  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)
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();
 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)
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)
tRPCJoin
Move Fast & Break Nothing. End-to-end typesafe APIs made easy.
5,015Members
Resources
Recent Announcements

Similar Threads

Was this page helpful?

Similar Threads

Can you ensureData without the useUtils hook?
ChenCChen / ❓-help
3y ago
TRPC 11 Classic React Query custom hook
Fitim BytyqiFFitim Bytyqi / ❓-help
10mo ago
trpc useError hook?
PeformPPeform / ❓-help
13mo ago
Can I use tRPC on multiple platforms?
IGMTCryptoIIGMTCrypto / ❓-help
12mo ago