React-native-elements: LIstItem component TouchableHighlight onPress not working

Created on 26 Nov 2017  Â·  3Comments  Â·  Source: react-native-elements/react-native-elements

Also posted here, but there is no SO tag for react-native-elements:

https://stackoverflow.com/questions/47491988/react-native-listitem-component-touchablehighlight-onpress-not-working

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}&nbsp;{item.foodType}&nbsp; <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?

Most helpful comment

The default component is already a TouchableHighlight, so a simple onPress should do the job?

<ListItem
  onPress={() => console.log('hey')}
  …
/>

All 3 comments

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]).

Was this page helpful?
0 / 5 - 0 ratings

Related issues

xiaoneng picture xiaoneng  Â·  3Comments

Slapbox picture Slapbox  Â·  3Comments

kyleatblackfoot picture kyleatblackfoot  Â·  3Comments

guitar9 picture guitar9  Â·  3Comments

jackcbrown89 picture jackcbrown89  Â·  3Comments