I am using the react-native-qrcode-scanner library to scan a barcode and return its result. However it does not read the barcode and returns no information
import React, { Component } from 'react';
import { View, Text, Dimensions, StyleSheet, TouchableOpacity } from 'react-native';
import QRCodeScanner from "react-native-qrcode-scanner";
export default class QRcodeScan extends Component {
state = {
id: ''
};
onSuccess = async (e) => {
console.log(e)
await this.setState({ id: e.data });
console.log(this.state.id)
};
render () {
return (
<QRCodeScanner
onRead={this.onSuccess}
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>
}
/>
);
}
}
const styles = StyleSheet.create({
centerText: {
flex: 1,
fontSize: 18,
padding: 32,
color: '#777',
},
textBold: {
fontWeight: '500',
color: '#000',
},
buttonText: {
fontSize: 21,
color: 'rgb(0,122,255)',
},
buttonTouchable: {
padding: 16,
},
});
- react-native-qrcode-scanner": "^1.3.1"
- react-native-permissions": "^2.0.3"
- react-native-camera": "^3.11.1"
- react-native": "^0.60.4"