Skip to content

Commit 14a032d

Browse files
authored
docs(react-query): add react background retry pausing documentation for v5 (#9755)
* docs: add react background retry pausing documentation for v5 * docs: add background retry behavior to query-retries guide
1 parent c578b3c commit 14a032d

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

docs/framework/react/guides/query-retries.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,28 @@ const result = useQuery({
7878
```
7979

8080
[//]: # '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+
return query.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

Comments
 (0)