Skip to content

Commit

Permalink
Apply queryClient.invalidateQueries on PersistQueryClientProvider. Re…
Browse files Browse the repository at this point in the history
…vert refetchOnMount=true for useBlockTimestamp and reactQuery
  • Loading branch information
nhohb committed Sep 18, 2024
1 parent 47363e3 commit 2efca82
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/hooks/chain/useBlockTimestamp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 6 additions & 0 deletions src/utils/query/providers.tsx
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -16,8 +17,13 @@ export function QueryProviders({ children }: Props) {
<PersistQueryClientProvider
client={queryClient}
persistOptions={createPersistConfig({ queryClient })}
onSuccess={() => {
return queryClient.invalidateQueries()
}}
>
{children}

<ReactQueryDevtoolsPanel client={queryClient} />
</PersistQueryClientProvider>
</WagmiProvider>
)
Expand Down
2 changes: 1 addition & 1 deletion src/utils/query/reactQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 2efca82

Please sign in to comment.