Skip to content

Commit

Permalink
Set stale time for query to 2 mins to reduce db queries
Browse files Browse the repository at this point in the history
  • Loading branch information
linkfang committed Dec 16, 2023
1 parent ea1f79a commit 5bab4a7
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,24 @@ import '@/styles/globals.css'
import dayjs from 'dayjs'
import isSameOrBefore from 'dayjs/plugin/isSameOrBefore'
import isSameOrAfter from 'dayjs/plugin/isSameOrAfter'
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'

dayjs.extend(isSameOrBefore)
dayjs.extend(isSameOrAfter)

const queryClient = new QueryClient({
defaultOptions: {
queries: { staleTime: 1000 * 120 },
},
})

const MyApp: AppType = ({ Component, pageProps }) => {
return (
<NavLayout>
<Component {...pageProps} />
</NavLayout>
<QueryClientProvider client={queryClient}>
<NavLayout>
<Component {...pageProps} />
</NavLayout>
</QueryClientProvider>
)
}

Expand Down

0 comments on commit 5bab4a7

Please sign in to comment.