moaazsidat / react-native-qrcode-scanner

A QR code scanner component for React Native.
MIT License
2.04k stars 516 forks source link

Cannot read property FlashMode of undefined #203

Open theone3nu opened 5 years ago

theone3nu commented 5 years ago

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={

Go to wikipedia.org/wiki/QR_code on your computer and scan the QR code.
            }
            bottomContent={
              <TouchableOpacity style={styles.buttonTouchable}>
                <Text style={styles.buttonText}>OK. Got it!</Text>
              </TouchableOpacity>
            }
          />

Build details?

Android OS

yaibait commented 5 years ago

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

Camera.Constants.FlashMode.torch `

x5engine commented 5 years ago

@yaibait thanks it works

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

Camera.Constants.FlashMode.torch
java-james commented 5 years ago

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>
      }
    />
renatobenks commented 4 years ago

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

renatobenks commented 4 years ago

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