when ever i scan a barcode in it reads but does not send any data or type and just sends an undefined value for it and thus i get an undifined is not a function error when I pass it to my action
import React, { Component } from "react";
import { View, Text, StyleSheet } from "react-native";
import { connect } from 'react-redux';
import { Button } from "react-native-elements";
import { BarCodeScanner, Permissions } from "expo";
import { itemUPC } from "../actions";
import { PRIMARY_COLOR } from "../constants/style";
class CameraScreen extends Component {
static navigationOptions = ({ navigation }) => (
{
// tabBarVisible: false,
title: "Camera",
tabBarLabel: "main",
headerTitleStyle: {
textAlign: "center",
alignSelf: "center"
},
headerLeft: (
<Button
navigate={navigation.navigate}
large
icon={{ name: "menu" }}
backgroundColor={PRIMARY_COLOR}
onPress={() => navigation.navigate("DrawerOpen")}
/>
)
});
state = {
hasCameraPermission: null
};
async componentWillMount() {
const { status } = await Permissions.askAsync(Permissions.CAMERA);
this.setState({ hasCameraPermission: status === 'granted' });
}
_handleBarCodeRead = (code) => {
this.props.navigation.navigate('searchResults');
this.props.itemUPC(code);
}
render() {
const { hasCameraPermission } = this.state;
if (hasCameraPermission === null) {
return <Text>Requesting for camera permission</Text>;
} else if (hasCameraPermission === false) {
return <Text>No access to camera</Text>;
} else {
return (
<View style={{ flex: 1 }}>
<BarCodeScanner
torchMode="on"
onBarCodeRead={this._handleBarCodeRead}
style={StyleSheet.absoluteFill}
/>
</View>
);
}
}
}
export default connect(null, itemUPC)(CameraScreen);