react-native-barcode-scanner-universal icon indicating copy to clipboard operation
react-native-barcode-scanner-universal copied to clipboard

Close on BarCodeRead

Open jmdelatorre opened this issue 7 years ago • 2 comments

Hi,

Im trying to open an alert when I scan a code, but the scanner keeps running, making various alerts

heres what I have..

<View style={{backgroundColor:'white',flex:1, justifyContent: 'center'}}>
    <View style={{width: window.width, height: window.height, alignItems: 'center'}}>
        <BarcodeScanner
              onBarCodeRead={(code) asd(code}
              style={styles.camera}>
              {scanArea}
         </BarcodeScanner>
    </View>
</View>

function asd(c) {

  console.log('asdsadsa');
  if (Platform.OS === 'ios') {
    AlertIOS.alert(
     'Scan Complete',
     c.data,
    );
  }
}

any fix? thanks

jmdelatorre avatar Sep 24 '16 18:09 jmdelatorre

Create a variable which indicates if a Barcode has already been recognized. If so, do nothing otherwise call the Alert function.

adnanbrq avatar Oct 18 '16 09:10 adnanbrq

something like this

constructor(props) {
    super(props)

    this.state = {
      qrcode: ''
    }
  }

onBarCodeRead={(code) => {
  if (code.data != this.state.qrcode) {
    this.setState({qrcode: code.data})
    Alert(code)
  }
}}

M1chaelTran avatar Nov 09 '16 07:11 M1chaelTran