ct3a with `react-query`
Hi! I am messing around with ct3a, and honeslty it's pretty good. Trpc is great, react-query is great, but even though I've read the docs, I am not sure how to call trpc procudere with
react-query
.
I've been trying whats in the docs also:
but seems like the useQuery
is not exists on the type:
the API
looks like this:
I am pretty sure I am missing something, but i am not sure what.
Any help would be appricaited! 🙂 Thakn you!8 Replies
did you add it to the root router?
yep, i did, if i call it like this:
it works.
do the procedures that came with the template work?
with the
useQuery
fn, it doesnt.
and i am readong now the corresponding trpc docs, and it looks like the setup on my end is ok too
i am assuming based on the docs, that this (from the template) should work:
but only the query
fn exists on the getLatest
are you in a server component?
useQuery
is a hook for client components
it returns loading state etc
using it in server components doesn't make any sense because you just await the data there
which is what query
doesohh yeah, i think thats going to be it. ive been just trying within the
src/app/page.tsx
from the ct3a template
so yeah, thats itlook at the difference between
page.tsx
and _components/create-post.tsx
the first is a server component
the second a client componenti forgot about this completely 🙈
yep! thank you sir!