Skip to content

Prefetching data on hover in combination with global loading indicator causes infinite rerenders #8716

Answered by TkDodo
Kukuliak-Dmytro asked this question in Q&A
Discussion options

You must be logged in to vote

I have tried to disable all refetch options in the queryClient

a) not a good idea as setting default options doesn’t affect already mounted instances and
b) this is not a matter of refetches, but of “staleTime”

prefetching respects staleTime, so every time the prefetching gets triggered, it will fire a request unless it sees fresh data in the cache. staleTime is zero per default, so it will always trigger a fetch when called.

Now in your case:

  • the user hovers the link, prefetch triggers
  • this triggers the overlay (which is above the link, so it triggers a mouseout)
  • fetch finishes, overlay goes away
  • this triggers the mouse cursor to hover the link again
  • this triggers another prefetch

no…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@Kukuliak-Dmytro
Comment options

@TkDodo
Comment options

@Kukuliak-Dmytro
Comment options

Answer selected by Kukuliak-Dmytro
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants