Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions docs/WRAPPER_REACT_QUERY.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# react-query wrapper

If you want to use MMKV with [react-query](https://tanstack.com/query/v4/docs/plugins/persistQueryClient), follow further steps:
If you want to use MMKV with [react-query](https://tanstack.com/query/latest/docs/framework/react/overview), follow further steps:

1. Install `react-query` persist packages

Expand Down Expand Up @@ -35,15 +35,20 @@ export const clientPersister = createSyncStoragePersister({ storage: clientStora
3. Use created `clientPersister` in your root component (eg. `App.tsx`)

```ts
import { PersistQueryClientProvider } from '@tanstack/react-query-persist-client'
import { persistQueryClient } from "@tanstack/react-query-persist-client";

persistQueryClient({
queryClient,
persister: clientPersister,
});

const App = () => {
return (
<PersistQueryClientProvider persistOptions={{ persister: clientPersister }}>
<QueryClientProvider client={queryClient}>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where's that import coming from?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

QueryClientProvider is imported from "@tanstack/react-query".

I didn't add it since it's required even for basic usage as well.

@mrousavy should I add this to the top?

import { QueryClientProvider } from "@tanstack/react-query";

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes please add that - then we can merge :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

{...}
</PersistQueryClientProvider>
</QueryClientProvider>
);
};
```

For more information check their official [docs](https://tanstack.com/query/v4/docs/plugins/persistQueryClient#persistqueryclientprovider)
For more information check their official [docs](https://tanstack.com/query/latest/docs/framework/react/plugins/createSyncStoragePersister)