listview - React Native ListView onEndReached 不断触发

标签 listview react-native ecmascript-6

出于某种我不明白的原因,即使我的 ListView 位于滚动的顶部,它也会继续触发,我需要将它包装在 ScrollView 中,因为我希望我的 ToolBar 在用户在 ListView 中向下滚动时也隐藏。

这是 render() 方法的内容:

<ScrollView>
    <ActivityContainer>
      <ListView
        onEndReachedThreshold={100}
        pageSize={10}
        initialListSize={20}
        onEndReached={() => {
                        console.log("fired"); // keeps firing
                      }}
        enableEmptySections={true}/>
    </ActivityContainer>
</ScrollView>

还尝试将整个事物包装在这样的 View 中:
<ScrollView>
   <View>
    <ActivityContainer>
      <ListView
        onEndReachedThreshold={100}
        pageSize={10}
        initialListSize={20}
        onEndReached={() => {
                        console.log("fired"); // keeps firing
                      }}
        enableEmptySections={true}/>
    </ActivityContainer>
   </View>
</ScrollView>

编辑:我不需要 renderHeader 因为我试图滚动 ListView 顶部的所有内容,它有许多组件和 View 以及 subview ,而不是 ListView 的标题。

最佳答案

看看这是否有效:

<ListView
  onEndReachedThreshold={100}
  pageSize={10}
  renderHeader={() => <ToolbarAndroid />}
  initialListSize={20}
  onEndReached={() => {
    console.log("fired"); // keeps firing
  }}
  enableEmptySections={true}/>

关于listview - React Native ListView onEndReached 不断触发,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38531369/

相关文章:

android - 如何为 TextView 定义 ColorStateList?

react-native - 你如何在 React Native 中 require() 一个声音文件?

javascript - 在 ES6/Babel 中重新导出整个模块

android - 用 espresso 断言列表中的正确数量的项目

android - 在 onCreateViewHolder 中获得位置

reactjs - 在自己的函数中响应导航 onPress

reactjs - 如何动态更改 React Native 堆栈导航屏幕的标题?

node.js - ES6 和 Node 中的同步和异步回调函数

Javascript 在类构造函数中调用类 (ES6)

android - 为什么我的 Android Listview 不滚动?