react-native-elements - android - <ListItem> onPress 参数不触发.......仅在调试时

问题描述

这是一个非常奇怪的问题....... 这只是昨天开始发生,我还没有进行任何代码更改。代码如下:

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}
/>

解决方法

想通了......显然在调试模式下......设备将常规按下解释为长按。我将 onLongPress 道具添加到 ListItem 并简单地复制了用于 onPress 的函数。有点黑客,但至少我可以继续工作。