报错: 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.
Goole 翻译: 无法在已卸载的组件上执行React状态更新。 这是空操作,但它表明应用程序中发生内存泄漏。 要解决此问题,请在componentWillUnmount方法中取消所有订阅和异步任务。
react项目切换路由的时候, 一直报这个错误,
最后在 点击按钮切换路由的那个页面,加了个卸载生命周期 componentWillUnmount
componentWillUnmount() {
this.setState = ()