T
TanStack•2y ago
wise-white

Keep error state when doing background refetch

Hi, currently the query behaves like so that when it's current state is error state it will trigger hard loading state on next network call and clear errors. On the other hand when there is success the hard loading is not triggered. Can I somehow achieve the same thing for errors?
4 Replies
deep-jade
deep-jade•2y ago
No i don't think so
wise-white
wise-whiteOP•2y ago
Interesting, I have such case in react-native:
const meQuery = trpc.me.useQuery();

if (meQuery.isLoading) {
return <Loader />;
}

return meQuery.isSuccess ? <ScreensForAuthedUsers /> : <ScreensForNonAuthedUsers />
const meQuery = trpc.me.useQuery();

if (meQuery.isLoading) {
return <Loader />;
}

return meQuery.isSuccess ? <ScreensForAuthedUsers /> : <ScreensForNonAuthedUsers />
Now while being inside SreensForNonAuthedUsers meQuery holds error state, if something triggers background refetch it causes the whole tree to unmount and shows loader screen. Wondering how to solve this issue...
deep-jade
deep-jade•2y ago
I would not make the query fail in that case
wise-white
wise-whiteOP•2y ago
Yeah makes sense, thanks 🙂

Did you find this page helpful?