UNPKG

inject-react-unmont

Version:

'解决异步请求时,出现不能在已经被销毁的组件中调用setState()方案。Can’t call setState (or forceUpdate) on an unmounted component '

34 lines (19 loc) 710 B
inject-react-unmont ======= 解决异步请求时,出现不能在已经被销毁的组件中调用setState()方案。Can’t call setState (or forceUpdate) on an unmounted component. 即出现该错误:'Warning: Can't call setState (or forceUpdate) 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. ' ## Install ```bash $ npm install inject-react-unmont ``` ## Usage 用法,that`s it ```js //引入 import inject_unmont from 'inject-react-unmont' @inject_unmont class myComponent extends Component { //.... } export default myComponent ```