4

我正在使用SectionList来显示数据列表。我有一个顶部菜单,用户可以单击这些按钮在列表上显示一组不同的数据,就像选项卡一样。所有这些都工作正常,正在显示正确的数据并且正在正确刷新。

然而问题是,当用户在列表上向下滚动时,比如说一半,然后单击顶部的按钮之一,列表不再显示refreshing动画(旋转的圆圈)。我已经正确实现了该refreshing属性,并且每当我下拉刷新时该属性都有效。

此外,如果您滚动到列表顶部,然后单击其中一个按钮,刷新图标也会按预期显示。问题是每当您向下滚动列表然后设置refreshing列表不显示图标的属性时。

<SectionList
refreshing={this.state.isFetching}
onRefresh={() => this.onRefreshList()}
....
...
/>

然后每当我打电话开始更新数据时......

this.setState({ isFetching: true }, function() {
....
....
//all code in here works fine the list shows activity monitor no problems
//when you scroll down on the list THEN 
//call this the activity monitor can't be seen on the list
});

因此,为了解决这个问题,我尝试在调用我的实际刷新之前自动滚动到顶部。这种工作,但它看起来真的很糟糕。没有回调,所以我不知道列表何时完成滚动到顶部。

//this also works properly and scrolls the list to the top but
//it's really jumpy and looks terrible because the data is immediately 
//replaced while it's scrolling to the top, the loading animation can't be seen.

 this.sectionListRef.scrollToLocation({
      animated: true,
      sectionIndex: 0,
      itemIndex: 0,
      viewPosition: 0
    });

这是一个已知的问题?是否有任何解决方法,或者我只是在这里做错了什么?

4

0 回答 0