From 2efca82fa2d2d6df9cc7ead278640947f60a8b47 Mon Sep 17 00:00:00 2001 From: Nho Huynh Date: Wed, 18 Sep 2024 11:21:12 +0700 Subject: [PATCH] Apply queryClient.invalidateQueries on PersistQueryClientProvider. Revert refetchOnMount=true for useBlockTimestamp and reactQuery --- src/hooks/chain/useBlockTimestamp.ts | 2 +- src/utils/query/providers.tsx | 6 ++++++ src/utils/query/reactQuery.ts | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/hooks/chain/useBlockTimestamp.ts b/src/hooks/chain/useBlockTimestamp.ts index 865dde78d..db8bd192e 100644 --- a/src/hooks/chain/useBlockTimestamp.ts +++ b/src/hooks/chain/useBlockTimestamp.ts @@ -12,7 +12,7 @@ export const useBlockTimestamp = ({ enabled = true }: UseBlockTimestampParameter blockTag: 'latest', query: { enabled, - refetchOnMount: 'always', + refetchOnMount: true, refetchInterval: 1000 * 60 * 5 /* 5 minutes */, staleTime: 1000 * 60 /* 1 minute */, select: (b) => b.timestamp * 1000n, diff --git a/src/utils/query/providers.tsx b/src/utils/query/providers.tsx index 9227d1217..0eca8ebf2 100644 --- a/src/utils/query/providers.tsx +++ b/src/utils/query/providers.tsx @@ -1,3 +1,4 @@ +import { ReactQueryDevtoolsPanel } from '@tanstack/react-query-devtools' import { PersistQueryClientProvider } from '@tanstack/react-query-persist-client' import type { ReactNode } from 'react' import { WagmiProvider } from 'wagmi' @@ -16,8 +17,13 @@ export function QueryProviders({ children }: Props) { { + return queryClient.invalidateQueries() + }} > {children} + + ) diff --git a/src/utils/query/reactQuery.ts b/src/utils/query/reactQuery.ts index c93241bb2..81047d639 100644 --- a/src/utils/query/reactQuery.ts +++ b/src/utils/query/reactQuery.ts @@ -5,7 +5,7 @@ export const queryClient = new QueryClient({ defaultOptions: { queries: { refetchOnWindowFocus: true, - refetchOnMount: 'always', + refetchOnMount: true, staleTime: 1_000 * 12, gcTime: 1_000 * 60 * 60 * 24, queryKeyHashFn: hashFn,