我正在使用 react-native FlatList 组件来列出项目
分页没有按预期发生,根据文档 onEndReached 在到达页面末尾时必须被触发,目前我尝试更改 onEndReachedThreshold 的值(尝试 0.1, 1.0, 0.5, 0.01 ),我也在设置刷新标志。
注意:我使用的是 ReactNative 0.48.4
所以这里我的代码
<Container style={{ marginTop: 22 }}>
<Content
style={{ flex: 1 }}
contentContainerStyle={{ flexGrow: 1 }}
>
<View style={{ flex: 1 }}>
<FlatList
initialNumToRender={10}
refreshing={this.state.refreshing}
onEndReachedThreshold={0.5}
onEndReached={({ distanceFromEnd }) => {
console.log('on end reached ', distanceFromEnd);
}}
data={this.props.messages}
renderItem={this.notificationContent.bind(this)}
keyExtractor={(item) => item._id}
/>
</View>
</Content>
</Container>
我已经尝试了所有可能的解决方案,作为对 github issues 的回应
有什么帮助吗?
最佳答案
您在项目中使用 NativeBase 并且 Flatlist 位于它们冲突的内容上。要解决此问题,您需要删除 Content
关于react-native - React Native FlatList Pagination 不起作用 - onEndReached 没有触发,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48740770/