【发布时间】:2018-12-07 09:06:11
【问题描述】:
我想在 React Native 中的 ListView 中实现 Pull-to-Refresh。
...
_onRefresh() {
this.setState({refreshing: true});
this._refreshData(this.course).then(() => {
this.setState({refreshing: false});
});
}
....
_refreshData(course) {
this.props.dispatch(clearLectures());
this.props.dispatch(fetchLectures(course));
}
....
return (
<ListView
dataSource={dataSource.cloneWithRowsAndSections(lectures)}
renderRow={this._renderRow}
renderSectionHeader={this._renderDayHeader}
refreshControl={
<RefreshControl
refreshing={this.state.refreshing}
onRefresh={this._onRefresh.bind(this)}
/>
}
/>
);
....
我收到以下错误:无法读取未定义的属性 'then'。
我必须在 _refreshData 函数中实现某种返回还是另一个问题?
【问题讨论】:
-
使您的 _refreshData 函数异步,以便它可以返回承诺
标签: listview react-native pull-to-refresh