React native0.43版本FlatList组件的onEndReached触发时间貌似在我已进入页面就触发了,看了下git的issue里有这么说,
然后貌似就不是我之前理解的onEndReached的了,并不能实现上拉加载更多的操作
随后有人给出了方法:
onScroll: function(){
if (this.refs.listview.scrollProperties.offset + this.refs.listview.scrollProperties.visibleLength >= this.refs.listview.scrollProperties.contentLength){
this.scrollEndReached();
}
},
render: function(){
return (
<View style={styles.container}>
<ListView
ref="listview"
onScroll={this.onScroll}
dataSource={this.state.dataSource}
renderRow={this.renderRow}
renderScene={this.renderScene}
renderHeader={this.renderHeader}
renderFooter={this.renderFooter}
onEndReached={this.onEndReached}
onEndReachedThreshold={2000}
automaticallyAdjustContentInsets={false}
keyboardDismissMode="on-drag"
keyboardShouldPersistTaps={true}
showsVerticalScrollIndicator={true} />
</View>
);
}
看代码使用es5写的,不知道是不是这个原因,我并不能按到这个list的scrollProperties属性值。
官网也说了,只触发一次
对于ListView实现上拉刷新和下拉加载更多我可以做到,但是就是想尝试下新的组件,据说可以防止内存泄漏。但是目前就卡在这个上拉加载更多了,请问
用RN0.43版本中的FlatList,如何实现上拉加载更多呢?
onEndReachedThreshold的值是0到1