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

时间:2017-11-15 13:29:51

标签: javascript react-native jsx

我需要在我的React-Native应用程序中在FlatList的顶部进行Pull to刷新,同时在FlatList的底部进行Pull to refresh。我可以使用refreshControl在顶部使用它,但我不知道如何将它放在顶部和底部。

1 个答案:

答案 0 :(得分:0)

FlatList组件具有预定义的功能。据我所知,你希望能够通过pull刷新刷新,当你到达列表的末尾时?如果是这样,您可以执行以下操作:

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 
/>