You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/framework/react/guides/query-retries.md
+25Lines changed: 25 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -78,3 +78,28 @@ const result = useQuery({
78
78
```
79
79
80
80
[//]: #'Example3'
81
+
82
+
## Background Retry Behavior
83
+
84
+
When using `refetchInterval` with `refetchIntervalInBackground: true`, retries will pause when the browser tab is inactive. This happens because retries respect the same focus behavior as regular refetches.
85
+
86
+
If you need continuous retries in the background, consider disabling retries and implementing a custom refetch strategy:
87
+
88
+
[//]: #'Example4'
89
+
90
+
```tsx
91
+
const result =useQuery({
92
+
queryKey: ['todos'],
93
+
queryFn: fetchTodos,
94
+
refetchInterval: (query) => {
95
+
// Refetch more frequently when in error state
96
+
returnquery.state.status==='error'?5000:30000
97
+
},
98
+
refetchIntervalInBackground: true,
99
+
retry: false, // Disable built-in retries
100
+
})
101
+
```
102
+
103
+
[//]: #'Example4'
104
+
105
+
This approach lets you control retry timing manually while keeping refetches active in the background.
0 commit comments