Skip to content

Commit 0a5d232

Browse files
committed
Add new guides for React Native createAsyncStoragePersister
1 parent 4690b58 commit 0a5d232

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

‎docs/plugins/createAsyncStoragePersister.md‎

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ yarn add @tanstack/query-async-storage-persister @tanstack/react-query-persist-c
1919
- Import the `createAsyncStoragePersister` function
2020
- Create a new asyncStoragePersister
2121
- you can pass any `storage` to it that adheres to the `AsyncStorage` interface - the example below uses the async-storage from React Native
22-
- Pass it to the [`persistQueryClient`](../plugins/persistQueryClient) function
22+
- Wrap your app by using [`PersistQueryClientProvider`](../plugins/persistQueryClient.md#persistqueryclientprovider) component.
2323

2424
```ts
2525
import AsyncStorage from '@react-native-async-storage/async-storage'
26-
import { persistQueryClient } from '@tanstack/react-query-persist-client'
26+
import { PersistQueryClientProvider } from '@tanstack/react-query-persist-client'
2727
import { createAsyncStoragePersister } from '@tanstack/query-async-storage-persister'
2828

2929
const queryClient = new QueryClient({
@@ -38,10 +38,16 @@ const asyncStoragePersister = createAsyncStoragePersister({
3838
storage: AsyncStorage
3939
})
4040

41-
persistQueryClient({
42-
queryClient,
43-
persister: asyncStoragePersister,
44-
})
41+
const Root = () => (
42+
<PersistQueryClientProvider
43+
client={queryClient}
44+
persistOptions={{ persister: asyncStoragePersister }}
45+
>
46+
<App />
47+
</PersistQueryClientProvider>
48+
);
49+
50+
export default Root;
4551
```
4652

4753
## Retries

0 commit comments

Comments
 (0)