Workflow-App/Workflow/components/QueryProvider.tsx

26 lines
706 B
TypeScript
Raw Permalink Normal View History

// components/QueryProvider.tsx
// Wraps the app in TanStack Query's QueryClientProvider. Lives high
// in the tree so all client components can call useQuery / useMutation.
"use client";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { useState } from "react";
export default function QueryProvider({ children }: { children: React.ReactNode }) {
const [client] = useState(
() =>
new QueryClient({
defaultOptions: {
queries: {
staleTime: 30_000,
refetchOnWindowFocus: false,
retry: 1
}
}
})
);
return <QueryClientProvider client={client}>{children}</QueryClientProvider>;
}