### Install React Instascan Source: https://context7.com/rubenspgcavalcante/react-instascan/llms.txt Install React Instascan and its peer dependencies using npm or yarn. ```bash # npm npm install react-instascan react instascan-umd --save # yarn yarn add react-instascan react instascan-umd ``` -------------------------------- ### Basic QR Code Reader with Scanner Component Source: https://context7.com/rubenspgcavalcante/react-instascan/llms.txt This example demonstrates a functional QR code reader using the Scanner component. It includes state management for scanning status and results, and event handlers for scan, start, stop, active, and inactive states. The camera is automatically selected and scanning starts on mount. ```jsx import React, { useState } from "react"; import { Cameras, Scanner } from "react-instascan"; function QRCodeReader() { const [scanning, setScanning] = useState(true); const [result, setResult] = useState(null); const handleScan = content => { console.log("Scanned:", content); setResult(content); }; const handleStart = () => console.log("Scanner started"); const handleStop = () => console.log("Scanner stopped"); const handleActive = () => console.log("Tab/scanner became active"); const handleInactive = () => console.log("Tab/scanner became inactive"); return (
{camerasOrError => { if (camerasOrError instanceof Error) { return

Error: {camerasOrError.message}

; } return ( {/* Must be a single ); }}
{result &&

Last scan: {result}

}
); } ``` -------------------------------- ### Install React Instascan with npm Source: https://github.com/rubenspgcavalcante/react-instascan/blob/master/README.md Use this command to install the library and its peer dependencies using npm. ```bash npm install react-instascan react instascan-umd --save ``` -------------------------------- ### Controlled Start/Stop Scanner Component Source: https://context7.com/rubenspgcavalcante/react-instascan/llms.txt This example shows how to control the scanner's start and stop states using the `stop` prop. The `onStart` and `onStop` callbacks are used to confirm the transitions, providing feedback on the scanner's operational status. ```jsx import React, { Component } from "react"; import { Cameras, Scanner } from "react-instascan"; class ControlledScanner extends Component { state = { stop: false }; toggle = () => this.setState(s => ({ stop: !s.stop })); render() { const { stop } = this.state; return (
{cameras => ( console.log("▶ Scanning started")} onStop={() => console.log("⏹ Scanning stopped")} onScan={content => console.log("QR:", content)} > )}
); } } ``` -------------------------------- ### Install React Instascan with yarn Source: https://github.com/rubenspgcavalcante/react-instascan/blob/master/README.md Use this command to install the library and its peer dependencies using yarn. ```bash yarn add react-instascan react instascan-umd ``` -------------------------------- ### Scanner Component Usage Source: https://context7.com/rubenspgcavalcante/react-instascan/llms.txt Demonstrates how to use the Scanner component to read QR codes. It includes setup for cameras, event handlers for scan results, and controls for starting/stopping the scanner. ```APIDOC ## Scanner Component `Scanner` creates and manages an `Instascan.Scanner` instance bound to a `