Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in the

 Can‘t perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in the componentWillUnmount method.

Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in the

 

 

解决:

componentWillUnmount里面增加 this.setState = () => false;   意思是将this.setState设置为false

例如:
  componentWillUnmount() {
     this.setState = () => false;
  }

  出现原因:某些时候请求接口数据加载比较慢,这时候setState还未完成,用户切换了组件或者切换页面时候,组件卸载了,而这个setState动作还在持续,所以react会出现警告

 

Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in the

上一篇:app的meta标签


下一篇:Android项目代码规范