Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

建议clearTimeout 一下 this._timer #5

Open
zuoge85 opened this issue Nov 10, 2017 · 1 comment
Open

建议clearTimeout 一下 this._timer #5

zuoge85 opened this issue Nov 10, 2017 · 1 comment

Comments

@zuoge85
Copy link

zuoge85 commented Nov 10, 2017

建议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.

@zuoge85
Copy link
Author

zuoge85 commented Nov 10, 2017

我使用如下代码解决

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;
  });
};

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

No branches or pull requests

1 participant