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


报错问题:
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()出现了来回切换界面的情况,正常情况应该只执行其一

(17.7.18)react 问题汇总之bind.js:1013 Warning: setState(...): Can only update a mounted or mounting comp_第1张图片

2.加一个else就ok了

(17.7.18)react 问题汇总之bind.js:1013 Warning: setState(...): Can only update a mounted or mounting comp_第2张图片


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

你可能感兴趣的:(个人问题问题汇总)