react-native-qrcode-scanner
react-native-qrcode-scanner copied to clipboard
Cannot read property FlashMode of undefined
Unable to detect constants from QRCodeScanner
What's happening?
when i add flashMode prop to the QRCodeScanner getting the above error
How can it be reproduced?
<QRCodeScanner onRead={this.onSuccess} flashMode={QRCodeScanner.Constants.FlashMode.torch} topContent={ <Text style={styles.centerText}> Go to <Text style={styles.textBold}>wikipedia.org/wiki/QR_code</Text> on your computer and scan the QR code. </Text> } bottomContent={ <TouchableOpacity style={styles.buttonTouchable}> <Text style={styles.buttonText}>OK. Got it!</Text> </TouchableOpacity> } />
Build details?
Android OS
I have the same problem, try this `import { RNCamera as Camera } from 'react-native-camera';
Camera.Constants.FlashMode.torch `
@yaibait thanks it works
import { RNCamera as Camera } from 'react-native-camera';
Camera.Constants.FlashMode.torch
I don't think the above is correct for the latest. flashMode no longer exists on QRCodeScanner by the looks instead it takes cameraProps.
This is the solution for me using latest
import QRCodeScanner from "react-native-qrcode-scanner";
import { RNCamera as Camera } from "react-native-camera";
<QRCodeScanner
onRead={onSuccess}
cameraProps={{ flashMode: Camera.Constants.FlashMode.auto }}
topContent={<Text style={styles.centerText}>Test</Text>}
bottomContent={
<TouchableOpacity style={styles.buttonTouchable}>
<Text style={styles.buttonText}>OK. Got it!</Text>
</TouchableOpacity>
}
/>
@moaazsidat why the constants it's no more available in QRCodeScanner? 🤔
@moaazsidat along #241 merged can we close this one?