Using `refetchOnWindowFocus` when I change it to false it fetches one more time!
See original GitHub issueI’m using this code to query my players
:
export let refetchEnabled: boolean;
$: players = useQuery("/players",
async () => await getPlayers(),
{ refetchOnWindowFocus: refetchEnabled }
);
but in this way when I switch refetchEnabled
to false
it refetches my players
one more time before stopping.
Am I wrong?
Issue Analytics
- State:
- Created 2 years ago
- Comments:7
Top Results From Across the Web
useQuery `refetchOnWindowFocus` option does not respect ...
Queries are fetched unnecessary even when retry is set to false , retryCount resets every time on window focus.
Read more >Window Focus Refetching | TanStack Query Docs
If a user leaves your application and returns to stale data, React Query automatically requests fresh data for you in the background.
Read more >React Query - refetch on window focus but not otherwise?
If i change the staleTime to Infinity like suggested in the question above, React Query would never refetch on window focus.
Read more >Fetch a query only once until page refresh using React Query
The network is reconnected. We turned off most of the library defaults because it's okay for the data we're displaying to be stale...
Read more >Window Focus Refetching | Svelte Query | SvelteStack
Window Focus Refetching. If a user leaves your application and returns to stale data, Svelte Query automatically requests fresh data for you in...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@amen-souissi can you please help here? Svelte newbie here. 😄
@amen-souissi are you still interested in keeping the project and helping people use it? I sincerely ask just to understand for the future, no criticism between the lines… 😃
Not that I’ve seen. I just found it in the source a while ago when I was looking for similar functionality.
Not really, but my supposition was that recreating the query is causing it to run the fetch again when you didn’t want it to.
As for the other questions, I think if you want to change the query key then you do have to actually recreate the whole query object.