【发布时间】:2019-06-28 11:17:25
【问题描述】:
当我在FlatList 中使用onEndReached 函数时,它会被自动调用。
以下是本期的链接。
是否有可用的解决方案或 iOS 中的任何替代方案?
已编辑:
以下是我尝试过的代码,但这似乎不起作用。
constructor(props){
super(props);
this.state = {
flatListReady:false
}
}
loadMore(){
if(!this.state.flatListReady){
return null;
}
else{
alert("End Reached")
}
}
_scrolled(){
this.setState({flatListReady:true});
}
render() {
return (
<Layout style={{ flex: 1 }}>
<FlatList
data={listData}
renderItem={({item}) => this._renderItem(item)}
keyExtractor={(item, index) => item.key}
onEndReached={() => this.loadMore()}
onEndReachedThreshold={0.5}
onScroll={() => this._scrolled()}
/>
</Layout>
【问题讨论】:
-
如果你能发布sn-p你到目前为止尝试了什么,你通过了哪些道具等等......和
-
@TrinadhKoya 请检查我更新的问题。 :)
-
移除onScroll
-
并在 this.loadMore() 周围添加大括号 {}
-
Gokul 还是不行。
标签: react-native react-native-ios react-native-flatlist