feat: add ReactScan component for enhanced development scanning (#29086)

This commit is contained in:
zhsama
2025-12-03 18:19:12 +08:00
committed by GitHub
parent c1fe394c0e
commit 0343374d52
5 changed files with 215 additions and 10 deletions

View File

@@ -0,0 +1,22 @@
'use client'
import { scan } from 'react-scan'
import { useEffect } from 'react'
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
}