m-pull-to-refresh
m-pull-to-refresh copied to clipboard
建议clearTimeout 一下 this._timer
建议clearTimeout 一下 this._timer
我在使用的时候发现犹豫没有clearTimeout this._timer,造成
setState(...): Can only update a mounted or mounting component. This usually means you called setState() on an unmounted component. This is a no-op. Please check the code for the PullToRefresh component.
我使用如下代码解决
RPullToRefresh.prototype.componentWillUnmount = function () {
this.destroy(this.props.getScrollContainer() || this.containerRef);
if(this._timer){
clearTimeout(this._timer);
}
if(this._initTimer){
clearTimeout(this._initTimer);
}
};
RPullToRefresh.prototype.componentDidMount = function () {
this._initTimer = setTimeout(() => {
this.init(this.props.getScrollContainer() || this.containerRef);
this.triggerPullToRefresh();
delete this._initTimer;
});
};