query-client.tsx 607 B

1234567891011121314151617181920212223
  1. 'use client'
  2. import type { FC, PropsWithChildren } from 'react'
  3. import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
  4. import { ReactQueryDevtools } from '@tanstack/react-query-devtools'
  5. const STALE_TIME = 1000 * 60 * 30 // 30 minutes
  6. const client = new QueryClient({
  7. defaultOptions: {
  8. queries: {
  9. staleTime: STALE_TIME,
  10. },
  11. },
  12. })
  13. export const TanstackQueryIniter: FC<PropsWithChildren> = (props) => {
  14. const { children } = props
  15. return <QueryClientProvider client={client}>
  16. {children}
  17. <ReactQueryDevtools initialIsOpen={false} />
  18. </QueryClientProvider>
  19. }