gameboyVito / react-native-ultimate-listview

A high performance FlatList providing customised pull-to-refresh | auto-pagination & infinite-scrolling | gridview layout | swipeable-row.
https://www.npmjs.com/package/react-native-ultimate-listview
MIT License
540 stars 87 forks source link

android 使用UltimateRefreshView 进入app会 一直是下拉状态 提示‘正在刷新’ #42

Open gao520sun opened 6 years ago

koupeng commented 6 years ago

我也是这个问题。

FaiChou commented 6 years ago

源码有问题

refreshableScrollView.ios.js line123

        this._isRefreshing = true
        this.setState({
          refreshStatus: RefreshStatus.refreshing,
          refreshTitle: this.props.refreshableTitleRefreshing
        })

setState是异步的, 刚刷新完并不会立即将状态设为refreshing 但是此时:

refreshableScrollView.ios.js line152

  onRefreshEnd = () => {
    // console.log('onRefreshEnd()');
    if (this.state.refreshStatus === RefreshStatus.refreshing) {

却判断了状态是不是refreshing . 可以去掉这个判断.

也可以在调用时候加个延迟, 或者放到数据请求完成/失败之后.

//      <UltimateRefreshView
//          onRefresh={this.pageRefresh}
//        >
 pageRefresh = (endRefresh) => {
    this.loadData();
    setTimeout(() => {
        endRefresh();
    }, 500);
  }