mirror of
https://github.com/langgenius/dify.git
synced 2026-05-03 00:48:04 +08:00
chore: update vinext, add workaround (#32878)
This commit is contained in:
@ -1,21 +1,15 @@
|
||||
'use client'
|
||||
|
||||
import { lazy, Suspense } from 'react'
|
||||
import Script from 'next/script'
|
||||
import { IS_DEV } from '@/config'
|
||||
|
||||
const ReactScan = lazy(() =>
|
||||
import('./scan').then(module => ({
|
||||
default: module.ReactScan,
|
||||
})),
|
||||
)
|
||||
|
||||
export const ReactScanLoader = () => {
|
||||
export function ReactScanLoader() {
|
||||
if (!IS_DEV)
|
||||
return null
|
||||
|
||||
return (
|
||||
<Suspense fallback={null}>
|
||||
<ReactScan />
|
||||
</Suspense>
|
||||
<Script
|
||||
src="//unpkg.com/react-scan/dist/auto.global.js"
|
||||
crossOrigin="anonymous"
|
||||
strategy="beforeInteractive"
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
@ -1,22 +0,0 @@
|
||||
'use client'
|
||||
|
||||
import { useEffect } from 'react'
|
||||
import { scan } from 'react-scan'
|
||||
import { IS_DEV } from '@/config'
|
||||
|
||||
export function ReactScan() {
|
||||
useEffect(() => {
|
||||
if (IS_DEV) {
|
||||
scan({
|
||||
enabled: true,
|
||||
// HACK: react-scan's getIsProduction() incorrectly detects Next.js dev as production
|
||||
// because Next.js devtools overlay uses production React build
|
||||
// Issue: https://github.com/aidenybai/react-scan/issues/402
|
||||
// TODO: remove this option after upstream fix
|
||||
dangerouslyForceRunInProduction: true,
|
||||
})
|
||||
}
|
||||
}, [])
|
||||
|
||||
return null
|
||||
}
|
||||
Reference in New Issue
Block a user