Search code examples
react-nativereact-native-elements

react-native-elements - android - <ListItem> onPress argument not triggering.......ONLY when debugging


This is a very strange one.....when I am not debugging everything works fine.....but as soon as I turn on debugging the onPress functionality of ListItem within FlatList no longer responds to a press. This only started happening yesterday and I havent made any code changes. Code below:

import { StyleSheet, Text, View, FlatList, ActivityIndicator, Alert } from 'react-native';
import {ListItem, Avatar} from 'react-native-elements';

<FlatList
  data={this.props.data}
  keyExtractor={(item, index) => {
    return index.toString();
  }}
    return (
      <View>
        <ListItem
          onPress={() => {
            this.props.flatListItemPressHandler(item);
          }}>
          <ListItem.Content>
            <ListItem.Title style={{fontWeight: 'bold', fontSize: 20}}>
              {item.name}
            </ListItem.Title>
          </ListItem.Content>
          <ListItem.Chevron />
        </ListItem>
      </View>
    );
  }}
  ItemSeparatorComponent={this.renderSeparator}
  onEndReached={this.props._handleLoadMore}
  onEndReachedThreshold={0.3}
/>

Solution

  • Figured it out....apparently when in debug mode....the device is interpreting a regular press as a long press. I added onLongPress prop to ListItem and simply copied the function used for onPress. Bit of a hack but at least I can continue working.