好的,所以我有两个屏幕,当 qrscanner 读取 qr 时它会导航到 InfoScreen,这一切都很好,但问题是即使屏幕是 InfoScreen,如果相机指向 qr 码它仍然会扫描。
我的问题是我如何检查现在的屏幕应用程序,以便我可以在 qrCodeOnReadHandler if(!qrscreen){return}
export default class Qr extends Component {
qrCodeOnReadHandler = ({ data }) => {
this.props.navigation.navigate("InfoScreen")
};
}
和
class InfoScreen extends Component {
render() {
return (
<View style={styles.buttons}>
<TouchableOpacity
style={styles.buttonStyle}
onPress={() => this.props.navigation.goBack()}
>
<Text style={styles.textStyle}>Back</Text>
</TouchableOpacity>
</View>
);
}
}