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
- This predicate function will be called for every single query in the cache and be expected to return truthy for queries that are `found`.
2362
2366
- The `exact` option has no effect with using a function
2363
2367
- `exact: Boolean`
2364
-
- If you don't want to search queries inclusively by query key, you can pass the `exact: true` option to return only the query with the exact query key you have passed. Don't remember to destructure it out of the array!
2368
+
- If you don't want to search queries inclusively by query key, you can pass the `exact: true` option to return only the query with the exact query key you have passed. Remember to destructure it out of the array!
2365
2369
- `throwOnError: Boolean`
2366
2370
- When set to `true`, this function will throw if any of the query refetch tasks fail.
- This predicate function will be called for every single query in the cache and be expected to return truthy for queries that are `found`.
2395
2399
- The `exact` option has no effect with using a function
2396
2400
- `exact: Boolean`
2397
-
- If you don't want to search queries inclusively by query key, you can pass the `exact: true` option to return only the query with the exact query key you have passed. Don't remember to destructure it out of the array!
2401
+
- If you don't want to search queries inclusively by query key, you can pass the `exact: true` option to return only the query with the exact query key you have passed. Remember to destructure it out of the array!
- This predicate function will be called for every single query in the cache and be expected to return truthy for queries that are `found`.
2422
2426
- The `exact` option has no effect with using a function
2423
2427
- `exact: Boolean`
2424
-
- If you don't want to search queries inclusively by query key, you can pass the `exact: true` option to return only the query with the exact query key you have passed. Don't remember to destructure it out of the array!
2428
+
- If you don't want to search queries inclusively by query key, you can pass the `exact: true` option to return only the query with the exact query key you have passed. Remember to destructure it out of the array!
2425
2429
2426
2430
### Returns
2427
2431
@@ -2522,6 +2526,18 @@ queryCache.clear()
2522
2526
- `queries:Array<Query>`
2523
2527
- This will be an array containing the queries that were found.
2524
2528
2529
+
## `useQueryCache`
2530
+
2531
+
The `useQueryCache` hook returns the current queryCache instance.
2532
+
2533
+
```js
2534
+
import { useQueryCache } from'react-query';
2535
+
2536
+
constqueryCache=useQueryCache()
2537
+
```
2538
+
2539
+
If you are using the `ReactQueryCacheProvider` to set a custom cache, you cannot simply import `{ queryCache }` any more. This hook will ensure you're getting the correct instance.
2540
+
2525
2541
## `useIsFetching`
2526
2542
2527
2543
`useIsFetching` is an optional hook that returns the `number` of the queries that your application is loading or fetching in the background (useful for app-wide loading indicators).
@@ -2582,6 +2598,29 @@ function App() {
2582
2598
- Must be **stable** or **memoized**. Do not create an inline object!
2583
2599
- For non-global properties please see their usage in both the [`useQuery` hook](#usequery) and the [`useMutation` hook](#usemutation).
2584
2600
2601
+
## `ReactQueryCacheProvider`
2602
+
2603
+
`ReactQueryCacheProvider` is an optional provider component for explicitly setting the query cache used by React Query. This is useful for creating component-level caches that are not completely global, as well as making truly isolated unit tests.
- In instance of queryCache, you can use the `makeQueryCache` factory to create this.
2622
+
- If not provided, a new cache will be generated.
2623
+
2585
2624
## `setConsole`
2586
2625
2587
2626
`setConsole` is an optional utility function that allows you to replace the `console` interface used to log errors. By default, the `window.console` object is used. If no global `console` object is found in the environment, nothing will be logged.
0 commit comments