This commit is contained in:
Stephen Zhou 2026-04-29 17:16:40 +08:00
parent e56d820ac4
commit f7cf0c050e
No known key found for this signature in database
2 changed files with 14 additions and 16 deletions

View File

@ -1,15 +0,0 @@
import type { QueryClient } from '@tanstack/react-query'
import { isServer } from '@/utils/client'
import { makeQueryClient } from './query-client-server'
let browserQueryClient: QueryClient | undefined
export function getQueryClient() {
if (isServer)
return makeQueryClient()
if (!browserQueryClient)
browserQueryClient = makeQueryClient()
return browserQueryClient
}

View File

@ -1,8 +1,21 @@
'use client'
import type { QueryClient } from '@tanstack/react-query'
import { QueryClientProvider } from '@tanstack/react-query'
import { TanStackDevtoolsLoader } from '@/app/components/devtools/tanstack/loader'
import { getQueryClient } from './get-query-client'
import { isServer } from '@/utils/client'
import { makeQueryClient } from './query-client-server'
let browserQueryClient: QueryClient | undefined
function getQueryClient() {
if (isServer) {
return makeQueryClient()
}
if (!browserQueryClient)
browserQueryClient = makeQueryClient()
return browserQueryClient
}
export const TanstackQueryInitializer = ({ children }: { children: React.ReactNode }) => {
const queryClient = getQueryClient()