From a204436a2651c27b9242379debd4c003a3160470 Mon Sep 17 00:00:00 2001 From: spookyuser <16196262+spookyuser@users.noreply.github.com> Date: Mon, 31 Mar 2025 11:00:18 +0200 Subject: [PATCH 1/3] Update createPersister.md with info about https://github.com/TanStack/query/issues/6310 --- docs/framework/react/plugins/createPersister.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/framework/react/plugins/createPersister.md b/docs/framework/react/plugins/createPersister.md index 24206b8bfc..64afc260c0 100644 --- a/docs/framework/react/plugins/createPersister.md +++ b/docs/framework/react/plugins/createPersister.md @@ -39,6 +39,8 @@ bun add @tanstack/query-persist-client-core - 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. +- Note: `queryClient.setQueryData()` operations are not peristed, this means that if you perform an optimistic update and refresh the page before the query has been invalidated your changes to the query data will be lost. See https://github.com/TanStack/query/issues/6310 + This way, you do not need to store whole `QueryClient`, but choose what is worth to be persisted in your application. Each query is lazily restored (when the Query is first used) and persisted (after each run of the `queryFn`), so it does not need to be throttled. `staleTime` is also respected after restoring the Query, so if data is considered `stale`, it will be refetched immediately after restoring. If data is `fresh`, the `queryFn` will not run. From c71c7d22508e8c8d4446702c01fd62f6b8bbbba1 Mon Sep 17 00:00:00 2001 From: spookyuser <16196262+spookyuser@users.noreply.github.com> Date: Mon, 31 Mar 2025 12:20:45 +0200 Subject: [PATCH 2/3] Fix typo --- docs/framework/react/plugins/createPersister.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/framework/react/plugins/createPersister.md b/docs/framework/react/plugins/createPersister.md index 64afc260c0..73f45fa1c6 100644 --- a/docs/framework/react/plugins/createPersister.md +++ b/docs/framework/react/plugins/createPersister.md @@ -39,7 +39,7 @@ bun add @tanstack/query-persist-client-core - 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. -- Note: `queryClient.setQueryData()` operations are not peristed, this means that if you perform an optimistic update and refresh the page before the query has been invalidated your changes to the query data will be lost. See https://github.com/TanStack/query/issues/6310 +- Note: `queryClient.setQueryData()` operations are not persisted, this means that if you perform an optimistic update and refresh the page before the query has been invalidated, your changes to the query data will be lost. See https://github.com/TanStack/query/issues/6310 This way, you do not need to store whole `QueryClient`, but choose what is worth to be persisted in your application. Each query is lazily restored (when the Query is first used) and persisted (after each run of the `queryFn`), so it does not need to be throttled. `staleTime` is also respected after restoring the Query, so if data is considered `stale`, it will be refetched immediately after restoring. If data is `fresh`, the `queryFn` will not run. From b4ad3c53aa120d8eec534a17cffc60f82dcc200e Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Thu, 10 Apr 2025 11:57:54 +0000 Subject: [PATCH 3/3] ci: apply automated fixes --- docs/framework/react/plugins/createPersister.md | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/framework/react/plugins/createPersister.md b/docs/framework/react/plugins/createPersister.md index 73f45fa1c6..5bd71b1e6b 100644 --- a/docs/framework/react/plugins/createPersister.md +++ b/docs/framework/react/plugins/createPersister.md @@ -41,7 +41,6 @@ bun add @tanstack/query-persist-client-core - If you provide this `persister` to a single `useQuery` hook, only this Query will be persisted. - Note: `queryClient.setQueryData()` operations are not persisted, this means that if you perform an optimistic update and refresh the page before the query has been invalidated, your changes to the query data will be lost. See https://github.com/TanStack/query/issues/6310 - This way, you do not need to store whole `QueryClient`, but choose what is worth to be persisted in your application. Each query is lazily restored (when the Query is first used) and persisted (after each run of the `queryFn`), so it does not need to be throttled. `staleTime` is also respected after restoring the Query, so if data is considered `stale`, it will be refetched immediately after restoring. If data is `fresh`, the `queryFn` will not run. Garbage collecting a Query from memory **does not** affect the persisted data. That means Queries can be kept in memory for a shorter period of time to be more **memory efficient**. If they are used the next time, they will just be restored from the persistent storage again.