Download components/contexts/tanstack-query-context.tsx from AnkhLP/deepsite: direct link, hf CLI and curl.
- Browser
- Download file 761 Bytes
-
https://huggingface.co/spaces/AnkhLP/deepsite/resolve/main/components/contexts/tanstack-query-context.tsx
- Command line
-
hf download hf://spaces/AnkhLP/deepsite/components/contexts/tanstack-query-context.tsx
-
curl -L -o tanstack-query-context.tsx https://huggingface.co/spaces/AnkhLP/deepsite/resolve/main/components/contexts/tanstack-query-context.tsx
761 Bytes
| "use client"; | |
| import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; | |
| import { ReactQueryDevtools } from "@tanstack/react-query-devtools"; | |
| import { useState } from "react"; | |
| export default function TanstackContext({ | |
| children, | |
| }: { | |
| children: React.ReactNode; | |
| }) { | |
| // Create QueryClient instance only once using useState with a function | |
| const [queryClient] = useState( | |
| () => | |
| new QueryClient({ | |
| defaultOptions: { | |
| queries: { | |
| staleTime: 60 * 1000, // 1 minute | |
| refetchOnWindowFocus: false, | |
| }, | |
| }, | |
| }) | |
| ); | |
| return ( | |
| <QueryClientProvider client={queryClient}> | |
| {children} | |
| <ReactQueryDevtools initialIsOpen={false} /> | |
| </QueryClientProvider> | |
| ); | |
| } | |