Skip to content
This repository has been archived by the owner on Jan 3, 2023. It is now read-only.

列表个数比较少的时候,会有个loading一直在闪 #46

Open
jShi-git opened this issue May 25, 2016 · 3 comments
Open

列表个数比较少的时候,会有个loading一直在闪 #46

jShi-git opened this issue May 25, 2016 · 3 comments
Labels

Comments

@jShi-git
Copy link

jShi-git commented May 25, 2016

如题

列表项比较多的时候没有这个问题出现

测试环境,ios,dev模式

测试效果如下图

11 pic

10 pic

抓包看请求发现,进入列表有的时候会请求两次同一页的数据,如果列表过少或列表为空,就会狂刷接口,page值递增,也不能说递增,有重复请求的递增,而且有丢页的现象
-1

@osdio
Copy link
Owner

osdio commented May 25, 2016

恩恩,这是个bug, 我待会看看,

@osdio osdio added the bug label May 25, 2016
@jShi-git
Copy link
Author

jShi-git commented May 26, 2016

@jShi-git
Copy link
Author

jShi-git commented May 26, 2016

@soliury

自己改了下,效果还可以,不用改页面结构,参考上面贴的stackoverflow的帖子
修改 layouts/TopicList.js

constructor(props) {
super(props);
var ds = new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2});
this.state = {
isLoadingTail: false,
ds: ds.cloneWithRows(props.data)
};
this.shouldComponentUpdate = PureRenderMixin.shouldComponentUpdate.bind(this);
}
getSCData() {
const {tab, limit, page, actions, data} = this.props;
if (data.length) {
actions.getTopicsByTab(tab, {
page: page + 1,
limit
});
this.setState({
isLoadingTail: false
});
}
}
_onEndReached() {
if (this.state.isLoadingTail) {
return;
}
this.setState({
isLoadingTail: true,
dataSource: this.getSCData()
});
console.log('onEndReached', this.state.isLoadingTail);
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants