react-native - 可触摸元素(如按钮、TouchableHighlight 等)在 FlatList 中不起作用

标签 react-native react-native-flatlist

FlatList 中的可触摸元素不会注册触摸。为什么下面的代码不起作用?任何帮助表示赞赏。谢谢。

_listener = () => {
    Alert.alert('Touched');
}

renderItem({item, index}){
    return<View>
      <Button
          title = "Button"
          color = "#ccc"
          onPress={this._listener}
      />
    </View>
}

最佳答案

如果您在平面列表中添加 extraData={this.state} ,您可以让它注册触摸。

关于react-native - 可触摸元素(如按钮、TouchableHighlight 等)在 FlatList 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44648321/

相关文章:

ios - React Native - iOS Collection View

android - react-native:找不到命令

reactjs - 防止重新渲染 flatlist React Native

react-native - 当 FlatList 正在加载新项目时,FlatList 项目不会响应触摸

android - React-Native:FlatList 中的反向 zIndex

javascript - Fetch API 方法中的 React Native Catch 不起作用

android - 无法在空对象 : react. gradle 上调用方法 doFirst()

javascript - Spinner 在 onEndReachedThreshold Flatlist 中不起作用

reactjs - React,如果多个效果 setState 一个值会发生什么?

android - React Native FlatList 没有呈现 Axios API 请求