Skip to content

Commit

Permalink
feat: QueryClientProvider ์„ค์ •
Browse files Browse the repository at this point in the history
  • Loading branch information
seong-hui committed Dec 30, 2024
1 parent f47e9bd commit 228d1d6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
import { StrictMode } from "react";
import { createRoot } from "react-dom/client";
import App from "./App.tsx";
import queryClient from "./queryClient.ts";
import { QueryClientProvider } from "@tanstack/react-query";
import { ReactQueryDevtools } from "@tanstack/react-query-devtools";

createRoot(document.getElementById("root")!).render(
<StrictMode>
<App />
<QueryClientProvider client={queryClient}>
<ReactQueryDevtools initialIsOpen={false} />
<App />
</QueryClientProvider>
</StrictMode>
);
16 changes: 16 additions & 0 deletions src/queryClient.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { QueryClient } from "@tanstack/react-query";

const queryClient = new QueryClient({
defaultOptions: {
queries: {
retry: 0, // API ์š”์ฒญ ์‹คํŒจ์‹œ ์žฌ์‹œ๋„ ํ•˜๋Š” ์˜ต์…˜ (์„ค์ •๊ฐ’ ๋งŒํผ ์žฌ์‹œ๋„)
staleTime: 1000 * 60 * 1, // 1๋ถ„ ํ›„ ๋ฐ์ดํ„ฐ๋Š” "stale"๋กœ ์ฒ˜๋ฆฌ
refetchOnWindowFocus: false, // window์— focus๋ฅผ ํ•˜๋ฉด refetch๊ฐ€ ์‹คํ–‰๋˜๋Š” ์˜ต์…˜ ๋„๊ธฐ
},
mutations: {
retry: 0, // API ์š”์ฒญ ์‹คํŒจ์‹œ ์žฌ์‹œ๋„ ํ•˜๋Š” ์˜ต์…˜ (์„ค์ •๊ฐ’ ๋งŒํผ ์žฌ์‹œ๋„)
},
},
});

export default queryClient;

0 comments on commit 228d1d6

Please sign in to comment.