Refetches after disabling
Hey there! I have a query which activates when a modal opens. It uses the
open variable to determine whether or not the query is enabled. Whenever I close and reopen the modal it refetches. Is there a way to precent this behaviour?3 Replies
sensitive-blue•4y ago
set a
staleTime for your query (or turn off refetchOnMount, but I would prefer the staleTime. read:
https://tkdodo.eu/blog/react-query-as-a-state-managerReact Query as a State Manager
Everything you need to know to make React Query your single source of truth state manager for your async state
sensitive-blue•4y ago
okay I didn't read the
enabled part correctly. I was assuming that opening a modal includes a mount event, but it seems like you are always rendering the modal and just visually hiding it?
In that case, staleTime is your only option.xenophobic-harlequinOP•4y ago
Okay, so I'd just set the staleTime to infite or 0?
Infinite it seems
Thanks, that helps a lot