繁体   English   中英

在React Native的FlatList中,如何在顶部(同时)在底部使用“拉动刷新”?

[英]How to use “Pull to refresh” in top and (at the same time) in bottom in a FlatList in React Native?

我需要在我的React-Native应用程序中在我的FlatList顶部刷新一个Pull,同时在该FlatList的底部刷新一个Pull。 我可以使用refreshControl在顶部使用它,但是我不知道该怎么做才能将其放在顶部和底部。

FlatList组件为此具有预定义的功能。 据我了解,您希望能够通过拉刷新来刷新,以及何时到达列表末尾? 如果是这样,您可以执行以下操作:

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM