2.0.8 • Published 5 years ago
react-fast-unmount v2.0.8
在数据加载还没完成 或者执行一些类似onscroll方法 ,组件销毁时后还改变数据报错如下:
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.
直接引用
import unject_unmount from 'react-fast-unmount'
然后再 自己需要的类上 @unject_unmount 如下
@unject_unmount
class Home extends PureComponent {
....
}
当然 当你使用Decorator 修饰符的 你可能会遇到这样的报错
> SyntaxError: C:UsersAdministratorDesktoptetestsrcapp.js: Support for the experimental syntax 'decorators-legacy' isn't currently enabled (15:1):