Skip to content

Commit

Permalink
Merge pull request #27 from linkfang/update-query-logic
Browse files Browse the repository at this point in the history
Set stale time for query to 2 mins to reduce db queries
  • Loading branch information
linkfang authored Dec 16, 2023
2 parents bd4ac0b + 5bab4a7 commit dbf1913
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 dbf1913

Please sign in to comment.