-
-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathQueryProvider.tsx
More file actions
37 lines (32 loc) · 837 Bytes
/
QueryProvider.tsx
File metadata and controls
37 lines (32 loc) · 837 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import { createContext } from 'react';
import { QueryClientProvider, QueryClient } from 'react-query';
export type GlobalOptions = {
apiKey: string;
apiUrl: string;
projectId: string | number | undefined;
branch?: string;
};
const queryClient = new QueryClient({
defaultOptions: {
queries: {
refetchOnWindowFocus: false,
refetchOnReconnect: false,
retry: false,
},
},
});
export const QueryContext = createContext({} as GlobalOptions);
type Props = GlobalOptions;
export const QueryProvider = ({
children,
apiUrl,
apiKey,
projectId,
branch,
}: React.PropsWithChildren<Props>) => {
return (
<QueryContext.Provider value={{ apiUrl, apiKey, projectId, branch }}>
<QueryClientProvider client={queryClient}>{children}</QueryClientProvider>
</QueryContext.Provider>
);
};