异步操作设置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
}
}组件生命周期图

相关文章:

  • 2021-07-19
  • 2021-04-07
  • 2021-09-15
  • 2022-01-14
猜你喜欢
  • 2022-12-23
  • 2021-12-03
  • 2021-10-16
  • 2021-10-10
相关资源
相似解决方案