react-native-qrcode-scanner icon indicating copy to clipboard operation
react-native-qrcode-scanner copied to clipboard

Cannot read property FlashMode of undefined

Open theone3nu opened this issue 6 years ago • 5 comments

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

theone3nu avatar Oct 06 '19 21:10 theone3nu

I have the same problem, try this `import { RNCamera as Camera } from 'react-native-camera';

Camera.Constants.FlashMode.torch `

yaibait avatar Oct 25 '19 15:10 yaibait

@yaibait thanks it works

import { RNCamera as Camera } from 'react-native-camera';

Camera.Constants.FlashMode.torch

x5engine avatar Nov 02 '19 16:11 x5engine

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>
      }
    />

java-james avatar Nov 17 '19 21:11 java-james

@moaazsidat why the constants it's no more available in QRCodeScanner? 🤔

renatobenks avatar May 04 '20 21:05 renatobenks

@moaazsidat along #241 merged can we close this one?

renatobenks avatar May 05 '20 19:05 renatobenks