Do TRPC fetches need to be wrapped in react.useeffect?

I'm curious on how the use of TRPC api calls works with client and server components. Does TRPC handling the caching of results or do we need to still wrap our calls in a react use effect to prevent unnecessary calls? thank you!
3 Replies
Mike
Mike7mo ago
tRPC react query is a wrapper around react query which is used for client-side caching https://www.npmjs.com/package/@trpc/react-query https://tanstack.com/query/latest
Mike
Mike7mo ago
you shouldn't wrap @trpc/react-query calls in a useEffect as it exposes hooks for you to make API calls for example useQuery: https://trpc.io/docs/client/react/useQuery
useQuery() | tRPC
The hooks provided by @trpc/react-query are a thin wrapper around @tanstack/react-query. For in-depth information about options and usage patterns, refer to their docs on queries.
Wiznet
Wiznet7mo ago
got it so its all really self contained then. thats great
Want results from more Discord servers?
Add your server