【发布时间】:2018-04-28 18:05:57
【问题描述】:
我需要在我的 React-Native 应用程序中在我的 FlatList 顶部有一个 Pull 来刷新,同时在该 FlatList 的底部有一个 Pull 来刷新。我可以使用 refreshControl 在顶部使用它,但我不知道如何将它放在顶部和底部。
【问题讨论】:
标签: javascript react-native jsx
我需要在我的 React-Native 应用程序中在我的 FlatList 顶部有一个 Pull 来刷新,同时在该 FlatList 的底部有一个 Pull 来刷新。我可以使用 refreshControl 在顶部使用它,但我不知道如何将它放在顶部和底部。
【问题讨论】:
标签: javascript react-native jsx
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
/>
【讨论】: