queryClient.refetchQueries() does not fire fetch if it's requested quickly after one
Hi, I have a query to REST API and I need to refetch this query after some websocket message(message tells that information updated and I need to refetch that info from REST API again).
I'm making first REST API call on page load. and there are cases, when I need to refetch information quickly after page loads(talking about less than 1sec after page loaded).
I have this console.log in. my fetch function for debugging
console.log("HTTP useMyAlertsQuery"); :
and I have this console.log("alerts_updated registered"); just before refetchQueries() call:
in my console log I'm getting:
and I'm not getting second HTTP useMyAlertsQuery log and nothing in my network tab also.
I also tried invalidateQueries with multiple different options. It was the same.
Is there some timelimit when cancelRefetch: true does not work? is there any other option to refetch required data? Maybe QueryKey not settled in yet?
any insights would be helpful, thank you1 Reply
fuzzy-lavenderOP•3y ago
it seems that it works when it's wrapped in requestAnimationFrame