[英]How to use “Pull to refresh” in top and (at the same time) in bottom in a FlatList in React Native?
I need in my React-Native app to have a Pull to refresh on the top of my FlatList and at the same time a Pull to refresh in the bottom of that FlatList. 我需要在我的React-Native应用程序中在我的FlatList顶部刷新一个Pull,同时在该FlatList的底部刷新一个Pull。 I can use refreshControl to use it at the top but I don't know what to do to put it in both top and bottom. 我可以使用refreshControl在顶部使用它,但是我不知道该怎么做才能将其放在顶部和底部。
The FlatList component has predefined functions for that. FlatList组件为此具有预定义的功能。 As i understand you want to be able to refresh via pull to refresh and when you are reaching the end of the list? 据我了解,您希望能够通过拉刷新来刷新,以及何时到达列表末尾? If so, you can do the following: 如果是这样,您可以执行以下操作:
handleRefresh = () => {
//make api calls
};
<FlatList
data={yourData}
onRefresh{this.handleRefresh} // handle pull to refresh
onEndReached={this.handleRefresh} // handle refresh
onEndReachedThreshold={1} // refresh as soon as the end of the list is reached. Probably you have to play around with this value
ListFooterComponent={this.renderFooter(this.props.loading)} // show activity indicator
/>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.