异步操作设置state导致组件被销毁后setState报错:Warning: 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.在销毁前清除state
使用代码:componentWillUnmount() {
this.setState = (state, callback) => {
return
}
}
组件生命周期图
最新推荐文章于 2022-12-02 10:26:23 发布