• 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.

    解决:

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

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

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

  • 相关阅读:
    《人月神话》-读后感2
    自主开发(二)
    自主开发(一)
    《人月神话》-读后感1
    公文流转系统—登录界面
    文件与流课堂实践
    Intern Day22
    Intern Day22
    Intern Day21
    计蒜客T1746
  • 原文地址:https://www.cnblogs.com/seemoon/p/13522432.html
Copyright © 2020-2023  润新知