npm.io
2.0.8 • Published 7 years ago

react-fast-unmount

Licence
ISC
Version
2.0.8
Deps
1
Size
3 kB
Vulns
0
Weekly
0

在数据加载还没完成 或者执行一些类似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):

那么欢迎点击这里进入我的github.