first
This commit is contained in:
commit
8538ab969a
434 changed files with 44051 additions and 0 deletions
28
apps/web/modules/shared/components/ApiClientProvider.tsx
Normal file
28
apps/web/modules/shared/components/ApiClientProvider.tsx
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
"use client";
|
||||
|
||||
import { createQueryClient } from "@shared/lib/query-client";
|
||||
import { type QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
||||
import type { PropsWithChildren } from "react";
|
||||
|
||||
let clientQueryClientSingleton: QueryClient;
|
||||
function getQueryClient() {
|
||||
if (typeof window === "undefined") {
|
||||
return createQueryClient();
|
||||
}
|
||||
|
||||
if (!clientQueryClientSingleton) {
|
||||
clientQueryClientSingleton = createQueryClient();
|
||||
}
|
||||
|
||||
return clientQueryClientSingleton;
|
||||
}
|
||||
|
||||
export function ApiClientProvider({ children }: PropsWithChildren) {
|
||||
const queryClient = getQueryClient();
|
||||
|
||||
return (
|
||||
<QueryClientProvider client={queryClient}>
|
||||
{children}
|
||||
</QueryClientProvider>
|
||||
);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue