Skip to content
Discussion options

You must be logged in to vote

As far as i know, prefetchQuery does nothing if there is already data in the cache. I’m not exactly sure what you are trying to achieve. Once you have data in the cache, if a new component mounts, it will use that cached data and do a background refetch to get the latest data.

if you want to fetch in an interval without having an actual useQuery, i think you want to use queryClient.fetchQuery in a useInterval. Dan Abramov shows a good impl of that hook here: https://overreacted.io/making-setinterval-declarative-with-react-hooks/

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@bennettdams
Comment options

@TkDodo
Comment options

@bennettdams
Comment options

Answer selected by bennettdams
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