refactor: extract ReactQueryProvider into dedicated context file

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
yuneng-jiang 2026-02-28 17:47:47 -08:00
parent c7d203366c
commit 8269f31921
3 changed files with 15 additions and 6 deletions

View file

@ -3,6 +3,7 @@ import { Inter } from "next/font/google";
import "./globals.css";
import AntdGlobalProvider from "@/contexts/AntdGlobalProvider";
import ReactQueryProvider from "@/contexts/ReactQueryProvider";
const inter = Inter({ subsets: ["latin"] });
@ -20,7 +21,9 @@ export default function RootLayout({
return (
<html lang="en">
<body className={inter.className}>
<AntdGlobalProvider>{children}</AntdGlobalProvider>
<ReactQueryProvider>
<AntdGlobalProvider>{children}</AntdGlobalProvider>
</ReactQueryProvider>
</body>
</html>
);

View file

@ -2,11 +2,8 @@
import React, { useEffect, useRef } from "react";
import { notification } from "antd";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { setNotificationInstance } from "@/components/molecules/notifications_manager";
const queryClient = new QueryClient();
export default function AntdGlobalProvider({ children }: { children: React.ReactNode }) {
const [api, contextHolder] = notification.useNotification();
const initialized = useRef(false);
@ -19,9 +16,9 @@ export default function AntdGlobalProvider({ children }: { children: React.React
}, [api]);
return (
<QueryClientProvider client={queryClient}>
<>
{contextHolder}
{children}
</QueryClientProvider>
</>
);
}

View file

@ -0,0 +1,9 @@
"use client";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
const queryClient = new QueryClient();
export default function ReactQueryProvider({ children }: { children: React.ReactNode }) {
return <QueryClientProvider client={queryClient}>{children}</QueryClientProvider>;
}