chore: update vinext, add workaround (#32878)

This commit is contained in:
Stephen Zhou
2026-03-03 11:21:04 +08:00
committed by GitHub
parent 4fd6b52808
commit d6ab36ff1e
7 changed files with 74 additions and 124 deletions

View File

@ -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"
/>
)
}

View File

@ -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
}