Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Turn flashlight on/off In QRcodeScanner React native

im using react-native-qrcode-scanner and what i want to do is : when user press on a flashlight icon flashLight go on i done this :

<QRCodeScanner
        showMarker
        onRead={this.onSuccess.bind(this)}
        cameraStyle={{ height: SCREEN_HEIGHT }}
        cameraProps={{ flashMode: this.state.flashLight ? RNCamera.Constants.FlashMode.on : RNCamera.Constants.FlashMode.off, captureAudio: false }}

camera prop works but when i change the state.flashLight (true or false) the flashLight not change

any Idea how change camera prop with state ??

like image 645
MoHammaD ReZa DehGhani Avatar asked Apr 30 '19 10:04

MoHammaD ReZa DehGhani


Video Answer


1 Answers

Try to replace:

RNCamera.Constants.FlashMode.on

with:

RNCamera.Constants.FlashMode.torch

Does the flashlight turn on now?

like image 161
Nino9612 Avatar answered Oct 03 '22 03:10

Nino9612