T
TanStack•2y ago
exotic-emerald

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
afraid-scarlet
afraid-scarlet•2y ago
No i don't think so
exotic-emerald
exotic-emeraldOP•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...
afraid-scarlet
afraid-scarlet•2y ago
I would not make the query fail in that case
exotic-emerald
exotic-emeraldOP•2y ago
Yeah makes sense, thanks 🙂

Did you find this page helpful?