import { useMemo } from "react"; import { encode } from "uqr"; type Props = { value: string; label: string; className?: string }; /** Dark modules on a white quiet zone so phone cameras can scan it on the dark theme. */ export function QrCode({ value, label, className }: Props) { const src = useMemo(() => { const qr = encode(value, { ecc: "M", border: 4 }); const size = qr.data.length; const segments: string[] = []; qr.data.forEach((row, y) => { row.forEach((dark, x) => { if (dark) segments.push(`M${x} ${y}h1v1h-1z`); }); }); const svg = ``; return `data:image/svg+xml,${encodeURIComponent(svg)}`; }, [value]); return {label}; }