T
TanStack13mo ago
rare-sapphire

Max refetch count

I am curious what is the proper way to refetch every x amount until maxRefetches has been reached.
const { data: job } = useQuery({
...getJobQueryOpts({
jobId: props.jobId!,
}),
refetchInterval: ({ state }) => {
const data = state.data

if (data?.nitems !== data?.nprocessed) {
return 1000 * 30 // Every 30 seconds
}

return false;
},
enabled: Boolean(props.jobId),
});
const { data: job } = useQuery({
...getJobQueryOpts({
jobId: props.jobId!,
}),
refetchInterval: ({ state }) => {
const data = state.data

if (data?.nitems !== data?.nprocessed) {
return 1000 * 30 // Every 30 seconds
}

return false;
},
enabled: Boolean(props.jobId),
});
Every refetch, the component re-renders right, so the state would re-render if i had like a refetchcount state
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?