Skip to main content

Scanner

A QR Code scanner.

Usage

import Scanner from "@fedibtc/ui"
import { useState } from "react"

function MyComponent() {
const [scanning, setScanning] = useState(false)

return (
<div>
<Button onClick={() => setScanning(true)}>Start Scanning</Button>

<Scanner
scanning={scanning && pInvoiceOpen}
onResult={result => {
console.log(result)
setScanning(false)
}}
onError={console.log}
/>
</div>
)
}

Props

NameTypeDescription
scanningbooleanWhether the scanner is actively scanning for QR codes.
onResult(result: string) => voidA function that is called when a QR code is successfully scanned.
onError(error: string) => voidA function that is called when an error occurs while scanning.