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/react-native.md
+29
Original file line number
Diff line number
Diff line change
@@ -95,6 +95,8 @@ In the above code, `refetch` is skipped the first time because `useFocusEffect`
95
95
96
96
## Disable queries on out of focus screens
97
97
98
+
### `subscribed` option
99
+
98
100
If you don’t want certain queries to remain “live” while a screen is out of focus, you can use the subscribed prop on useQuery. This prop lets you control whether a query stays subscribed to updates. Combined with React Navigation’s useIsFocused, it allows you to seamlessly unsubscribe from queries when a screen isn’t in focus:
99
101
100
102
Example usage:
@@ -119,3 +121,30 @@ function MyComponent() {
119
121
```
120
122
121
123
When subscribed is false, the query unsubscribes from updates and won’t trigger re-renders or fetch new data for that screen. Once it becomes true again (e.g., when the screen regains focus), the query re-subscribes and stays up to date.
124
+
125
+
### `PauseManagerProvider` option
126
+
127
+
In case you want to disable updates to _all_ queries in an out of focus screen, one alternative is to control them via `PauseManager`:
0 commit comments