Closed saturnonearth closed 2 years ago
This is an expected behavior, queries are also re-started if you navigate again on this page.
If you want to avoid some errors to be retried (eg: 404, 403, etc.), you can use the retry
option:
// on a specific query
const query = useQuery("users", loadUsers, {
retry: (failureCount, err) => failureCount < 3 && (err.status !== 403 || err.status !== 404),
});
// or globally
const client = new QueryClient({
defaultOptions: {
queries: {
retry: (failureCount, err) => failureCount < 3 && (err.status !== 403 || err.status !== 404),
},
},
});
If a query fails and retries 6 times, it stops, but then re-starts on window re-focus.