I am somewhat at a loss as to why I keep getting TypeError: Chat.onCameraClick is not a function. (In 'Chat.onCameraClick()', 'Chat.onCameraClick' is undefined)
.
I have the following:
export default class Chat extends React.Component {
static navigationOptions = ({ navigation }) => ({
title: 'Chat',
headerTintColor: colors.HEADERTINT,
headerStyle: {
backgroundColor: colors.HEADER,
},
headerLeft: () => (
<TouchableOpacity onPress={() => navigation.dispatch(DrawerActions.openDrawer())}>
<Icon
name="menu"
size={24}
style={{ color: colors.BLACK, marginLeft: 10 }}
/>
</TouchableOpacity>
),
headerRight: () => (
<TouchableOpacity onPress={() => this.onCameraClick()}>
<Icon
name="camera"
type='font-awesome'
size={24}
style={{ color: colors.BLACK, marginRight: 10 }}
/>
</TouchableOpacity>
),
});
Further down, I just have the camera method:
onCameraClick = () => {
console.log("Pic!");
}
I looked at posts like RN TouchableOpacity onPress dosn't call function and the touchableopacity docs here https://facebook.github.io/react-native/docs/touchableopacity but I am unsure as to why this would be "undefined" I have also tried to just call onPress={this.onCameraClick}
but basically the same happens.
What am I missing here?