T
TanStack3y ago
optimistic-gold

getQueryState result isn’t reactive

I'm calling queryClient.getQueryState(['current-user'])?.status === 'error' in a Match statement but despite the query erroring, the conditional never renders In order to account for this I hacked it into an effect
let timerId: number | undefined;
createEffect(() => {
timerId = setInterval(() => {
setUserWasError(queryClient.getQueryState(['current-user'])?.status === 'error');
});
}, 500);

onCleanup(() => {
clearInterval(timerId);
});
let timerId: number | undefined;
createEffect(() => {
timerId = setInterval(() => {
setUserWasError(queryClient.getQueryState(['current-user'])?.status === 'error');
});
}, 500);

onCleanup(() => {
clearInterval(timerId);
});
But this seems bad. Is there a better way?
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?