From 5bab4a7a16f691d1b987399e266bdece66da685b Mon Sep 17 00:00:00 2001 From: zhou fang Date: Sat, 16 Dec 2023 14:53:35 -0500 Subject: [PATCH] Set stale time for query to 2 mins to reduce db queries --- src/pages/_app.tsx | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/pages/_app.tsx b/src/pages/_app.tsx index 292759a..cbc9375 100644 --- a/src/pages/_app.tsx +++ b/src/pages/_app.tsx @@ -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 ( - - - + + + + + ) }