diff --git a/src/components/ui/qrcode.tsx b/src/components/ui/qrcode.tsx index 8cc0011..81df85c 100644 --- a/src/components/ui/qrcode.tsx +++ b/src/components/ui/qrcode.tsx @@ -12,21 +12,14 @@ export function QRCodeCanvas({ value, size = 256, level = 'M', className }: QRCo const canvasRef = useRef(null); useEffect(() => { - if (!canvasRef.current) return; - - QRCode.toCanvas( - canvasRef.current, - value, - { - width: size, - margin: 1, - errorCorrectionLevel: level, - }, - (error) => { - if (error) console.error('QR Code generation error:', error); - } - ); + if (!canvasRef.current || !value || value.length < 4) return; + const el = canvasRef.current; + try { + QRCode.toCanvas(el, value, { width: size, margin: 1, errorCorrectionLevel: level }); + } catch { + // silently skip on invalid input + } }, [value, size, level]); - return ; + return ; }