Replies: 1 comment 1 reply
-
Does this work for you? This ensures it refetches the data when the modal is open and the window regains focus. export function useOptionsQuery(isModalOpen: boolean) {
return useQuery({
// ...
refetchOnWindowFocus: isModalOpen ? 'always' : false,
});
} |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, I have a query about a list of options on a modal like this. Most of the time the modal is not opened.
I would like it to keep fresh if the user still uses the window but is invalidated after focusing.
However, if I set the
refetchOnWindowFocus
to always, the data is updating no matter if the modal is open. I don't want it to fetch data if the data is not mounted.How can I invalidate a query on the window focus?
Beta Was this translation helpful? Give feedback.
All reactions