Skip to content

How to set refetchInterval for only one useQuery function #5183

Closed Answered by TkDodo
Sannnji asked this question in Q&A
Discussion options

You must be logged in to vote

I don't fully understand the question, but: extract it to a custom hook and enable interval with a param?

const usePolls = (refetchInterval) =>
  useQuery({ querKey, queryFn, refetchInterval })

usePolls() // no interval
usePolls(5000) // with interval

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Sannnji
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