onSuccess, onError and onSettled deprecated next major version?
with
onSuccess
, onError
and onSettled
being deprecated soon™️, what would the best practice be for triggering side effects, when a trpc call is successful?
i should clarify, i'm not talking about putting the returned data in state. i'm talking about refreshing a route in a "use client"
component with next/router
, or toggling a boolean in a jotai store.Solution:Jump to solution
Breaking React Query's API on purpose
Why good API design matters, even if it means breaking existing APIs in the face of resistance.
10 Replies
Solution
Breaking React Query's API on purpose
Why good API design matters, even if it means breaking existing APIs in the face of resistance.
cheers
Hi just read through the article, everything makes sense but in the t3 setup there isn’t a way to do what they did regarding toasting an error, bc the onError callback from trpc occurs on the server side, inside the pages/api folder?
I could very well be wrong but could someone enlighten me on how to do useQuery error handling w trpc?
Breaking React Query's API on purpose
Why good API design matters, even if it means breaking existing APIs in the face of resistance.
The RQ api got changed, removing the onError/onSuccess callbacks.
There is examples on that page of handling errors now with use effect
or at teh queryClient level
lol
oh whoops :p
Yeah this is what I wanted to do but can’t find the queryClient config in the t3 setup
if you're using pages then inside
utils/api
you can set the queryClientConfig prop.
on app then you just pass it into the new QueryClient(config)
inthe rootPerfect thanks mate