mirror of https://github.com/langgenius/dify.git
refactor(web): use standardized Loader pattern for TanStack devtools
This commit is contained in:
parent
04648fc99a
commit
bb5a654f8d
|
|
@ -1,3 +1,2 @@
|
|||
export { ReactScan } from './react-scan'
|
||||
export { ReactScanLoader } from './react-scan'
|
||||
export { TanStackDevtoolsWrapper } from './tanstack'
|
||||
export * from './react-scan'
|
||||
export * from './tanstack'
|
||||
|
|
|
|||
|
|
@ -1 +1,2 @@
|
|||
export { TanStackDevtoolsWrapper } from './devtools'
|
||||
export { TanStackDevtoolsLoader } from './loader'
|
||||
|
|
|
|||
|
|
@ -0,0 +1,21 @@
|
|||
'use client'
|
||||
|
||||
import { lazy, Suspense } from 'react'
|
||||
import { IS_DEV } from '@/config'
|
||||
|
||||
const TanStackDevtoolsWrapper = lazy(() =>
|
||||
import('./devtools').then(module => ({
|
||||
default: module.TanStackDevtoolsWrapper,
|
||||
})),
|
||||
)
|
||||
|
||||
export const TanStackDevtoolsLoader = () => {
|
||||
if (!IS_DEV)
|
||||
return null
|
||||
|
||||
return (
|
||||
<Suspense fallback={null}>
|
||||
<TanStackDevtoolsWrapper />
|
||||
</Suspense>
|
||||
)
|
||||
}
|
||||
|
|
@ -2,14 +2,7 @@
|
|||
|
||||
import type { FC, PropsWithChildren } from 'react'
|
||||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
||||
import { lazy, Suspense } from 'react'
|
||||
import { IS_DEV } from '@/config'
|
||||
|
||||
const TanStackDevtoolsWrapper = lazy(() =>
|
||||
import('@/app/components/devtools/tanstack').then(module => ({
|
||||
default: module.TanStackDevtoolsWrapper,
|
||||
})),
|
||||
)
|
||||
import { TanStackDevtoolsLoader } from '@/app/components/devtools'
|
||||
|
||||
const STALE_TIME = 1000 * 60 * 30 // 30 minutes
|
||||
|
||||
|
|
@ -26,11 +19,7 @@ export const TanstackQueryInitializer: FC<PropsWithChildren> = (props) => {
|
|||
return (
|
||||
<QueryClientProvider client={client}>
|
||||
{children}
|
||||
{IS_DEV && (
|
||||
<Suspense fallback={null}>
|
||||
<TanStackDevtoolsWrapper />
|
||||
</Suspense>
|
||||
)}
|
||||
<TanStackDevtoolsLoader />
|
||||
</QueryClientProvider>
|
||||
)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue