[英]QR Scanner react-native crash on second invocation
Im using react-native-qrcode-scanner from https://github.com/moaazsidat/react-native-qrcode-scanner and I read perfectly the code but when I go back to qr-scanner again it crashes.我使用来自https://github.com/moaazsidat/react-native-qrcode-scanner 的react-native-qrcode-scanner 并且我完美地阅读了代码,但是当我再次回到 qr-scanner 时它崩溃了。 I think it is because the camera is still working on background, there is a way to close it when it ends?
我认为这是因为相机仍在后台工作,有没有办法在结束时关闭它?
The following solution worked for navigation between Camera screen and others:以下解决方案适用于相机屏幕和其他屏幕之间的导航:
In Constructor:在构造函数中:
this.state = {
focusedScreen: true
};
In render:在渲染中:
render() {
const { focusedScreen } = this.state;
if (!focusedScreen){
return <View />;
} else
{
return (
<QRCodeScanner ............
)
}
<QRCodeScanner
onRead={this.onSuccess.bind(this)}// change {this.onSuccess} to {this.onSuccess.bind(this)}
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>
}
/>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.