From 37b5cf07f791d8bc607c6dd9b6bfeda7014217ed Mon Sep 17 00:00:00 2001 From: Gaubee Date: Fri, 26 Dec 2025 16:49:56 +0800 Subject: [PATCH] fix(scanner): always render video element to avoid race condition The video element was conditionally rendered based on state, but initCamera tried to set srcObject before state changed to 'scanning'. This caused videoRef.current to be null in production. Fix: Always render video, use CSS 'invisible' to hide it when not active. --- src/pages/scanner/index.tsx | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/pages/scanner/index.tsx b/src/pages/scanner/index.tsx index 7a4cc80..bb4a08c 100644 --- a/src/pages/scanner/index.tsx +++ b/src/pages/scanner/index.tsx @@ -304,9 +304,16 @@ export function ScannerPage({ onScan, className }: ScannerPageProps) { {/* Camera viewfinder */}
- {(state === 'scanning' || state === 'success') && ( -