From 0a1eea51a65aacfbd9a844ba31592d8e5d8052df Mon Sep 17 00:00:00 2001 From: Innei Date: Thu, 19 Oct 2023 12:59:22 +0800 Subject: [PATCH] fix: indexDb in server --- src/providers/root/react-query-provider.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/providers/root/react-query-provider.tsx b/src/providers/root/react-query-provider.tsx index 24270db526..771dd317cf 100644 --- a/src/providers/root/react-query-provider.tsx +++ b/src/providers/root/react-query-provider.tsx @@ -8,7 +8,9 @@ import type { PropsWithChildren } from 'react' import { createAsyncStoragePersister } from '@tanstack/query-async-storage-persister' -const dbStore = createStore('react-query', 'queries') +import { isServerSide } from '~/lib/env' + +const dbStore = isServerSide ? undefined : createStore('react-query', 'queries') const asyncStoragePersister = createAsyncStoragePersister({ storage: { @@ -45,7 +47,10 @@ const persistOptions: Omit = { if (query.meta?.persist === false) return false if (queryIsReadyForPersistance) { - return !((query.state?.data as any)?.pages?.length > 1) + return ( + !((query.state?.data as any)?.pages?.length > 1) || + (!!query.state.data && !(query.state.data as any).pages) + ) } else { return false }