yudielcurbelo / react-qr-scanner

A library to scan QR Codes in react.
https://yudielcurbelo.github.io/react-qr-scanner/
MIT License
223 stars 31 forks source link

Can not turn on/off browser's camera by using setState #47

Closed vanthao-github closed 2 months ago

vanthao-github commented 4 months ago

Sorry, but I don't know how to turn the browser's camera off/on using setState. I could do it in version 1.2.10, but it seems unstable. Sometimes I can turn off the camera, but sometimes I can't.

BrunoTeixeiraNDB commented 4 months ago

In the new version presented, it is possible to access in the following way

import { Scanner, boundingBox, } from "@yudiel/react-qr-scanner";

const [enabled, setEnabled] = useState(false);

<Scanner onScan={handleScanWebCam} paused={enabled} constraints={{facingMode: cameraFacingMode}} components={{ audio: false, onOff: false, // the onOff controls the scanner torch: false, tracker: getTracker() }} />

At least that's what I understand until now when the official documentation isn't out. rsrs...

vanthao-github commented 4 months ago

Thank for replied @BrunoTeixeiraNDB , let me try your method. Thanks again!

yudielcurbelo commented 4 months ago

If what you want is to start with the camera off, you could try to pass false to the pause prop. Please let me know.

stale[bot] commented 3 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.