Catlike
Catlike
TtRPC
Created by Catlike on 7/19/2024 in #❓-help
Pass query as prop with ProcedureUseQuery
I'm trying to pass a query to a component in my client using TypeScript, but ProcedureUseQuery seems to not be exported in @trp/react-query 11.0 (it is defined on src/createTRPCReact.tsx)
2 replies
TtRPC
Created by Catlike on 5/7/2024 in #❓-help
useUtils changes at every render and causes useEffect to be called continuously
I have a context provider where I need to invalidate a query on unmount. So I wrote this piece of code:
const utils = trpc.useUtils();
useEffect(() => (
() => utils.user.example.invalidate()
), [utils.user.example.invalidate]);
const utils = trpc.useUtils();
useEffect(() => (
() => utils.user.example.invalidate()
), [utils.user.example.invalidate]);
Howerver, the cleanup function is called continuously when other fields of the context provider changes even without involving trpc. I also tried to use as dependency utils, utils.user and utils.user.example. A workaround coul be to pass [] as dependencies and then make an exception on eslint, but it would be nice if useUtils would return the same instance instead of changing at every render.
4 replies