Skip to content
Source
Sign inSign up
TanStack/query

fix(experimental_createQueryPersister): return more utilities, rename persister #8062

MergedDamianOsipiuk(GitHub profile, opens in a new tab)merged 5 commits intomain fromrefs/pull/8062/headmerged by DamianOsipiuk(GitHub profile, opens in a new tab) View on GitHub

Showing 7 changed files with 85 additions and 29 deletions (loading 4).

x
0 of 7 viewed, 7 left
68 additions and 15 deletionsdocs/framework/react/plugins/createPersister.mdModified
View file
@@ -1,6 +1,6 @@
---
id: createPersister
-title: experimental_createPersister
+title: experimental_createQueryPersister
---
​
## Installation
@@ -33,9 +33,9 @@
​
## Usage
​
-- Import the `experimental_createPersister` function
-- Create a new `experimental_createPersister`
- - you can pass any `storage` to it that adheres to the `AsyncStorage` or `Storage` interface - the example below uses the async-storage from React Native.
+- Import the `experimental_createQueryPersister` function
+- Create a new `experimental_createQueryPersister`
+ - you can pass any `storage` to it that adheres to the `AsyncStorage` interface - the example below uses the async-storage from React Native.
- Pass that `persister` as an option to your Query. This can be done either by passing it to the `defaultOptions` of the `QueryClient` or to any `useQuery` hook instance.
- If you pass this `persister` as `defaultOptions`, all queries will be persisted to the provided `storage`. You can additionally narrow this down by passing `filters`. In contrast to the `persistClient` plugin, this will not persist the whole query client as a single item, but each query separately. As a key, the query hash is used.
- If you provide this `persister` to a single `useQuery` hook, only this Query will be persisted.
@@ -48,16 +48,18 @@
```tsx
import AsyncStorage from '@react-native-async-storage/async-storage'