Also posted here, but there is no SO tag for react-native-elements:
I have the following React Native ListItem and the onPress is not logging to the console:
<ListItem
rightIcon={{name: 'delete', style: {color: 'white'}}}
component={TouchableHighlight}
containerStyle={styles[item.foodType]}
title={<Text style={styles[item.foodType]}>{item.amount} {item.foodType}
<FormattedDateTime epoch={item.when}/></Text>}>
onPress={() => console.log("Feeding", item) }
</ListItem>
Everything else works fine, list looks good, etc... I have tried without the component definition, making the right icon onPress as well, and more.
Why do I not see the message?
The default component is already a TouchableHighlight, so a simple onPress should do the job?
<ListItem
onPress={() => console.log('hey')}
…
/>
The closing tag was before the onPress props. (Cf Stackoverflow answer)
Use prop underlayColor to achieve TouchableHighlight ([email protected]).
Most helpful comment
The default component is already a
TouchableHighlight, so a simpleonPressshould do the job?