(17.7.18)react 问题汇总之bind.js:1013 Warning: setState(...): Can only update a mounted or mounting comp

来源:互联网 发布:视频画面剪切软件 编辑:程序博客网 时间:2024/06/11 22:06

报错问题:
bind.js:1013

Warning: 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


出现原因是:setState在组件销毁时执行了方法,出现了这个错误;

主要是从A页面切换到B页面然后马上又切换到另外的页面导致B页面的setState方法执行时就已经将B页面的组件销毁了;


发生实例:

1.执行方法backTo函数时if语句执行 后又执行了window.history.back()出现了来回切换界面的情况,正常情况应该只执行其一


2.加一个else就ok了



bind.js:1013Warning: 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
阅读全文
0 0