【问题标题】:react-native-elements - android - <ListItem> onPress argument not triggering.......ONLY when debuggingreact-native-elements - android - <ListItem> onPress 参数未触发.......仅在调试时
【发布时间】:2021-02-12 02:53:53
【问题描述】:

这是一个非常奇怪的问题.....当我不调试时,一切正常......但是一旦我打开调试 FlatList 中 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}
/>

【问题讨论】:

  • 同样的问题,通过你的问题发现它只是处于调试模式。谢谢。

标签: react-native react-native-android react-native-elements


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-09-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多