出于某种我不明白的原因,即使我的 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/