T
TanStack3y ago
deep-jade

Mutation status polling

Consider the following scenario. User clicks a button (mutation) and this kicks off a job in the background. I then need to poll a status endpoint for a success response. Technically the mutation isn’t done until I receive the response or an error. What is the recommended approach to handle this situation in react-query?
1 Reply
other-emerald
other-emerald2y ago
I have implemented this similarly using a "doPolling" state variable and setting enabled: doPolling in the query configuration. When the user submits the initial request, we set doPolling to True, and once the response comes back in a form we're good with, we set it back to false

Did you find this page helpful?