天天看點

react異常:Can‘t perform a React state update on an unmounted component[已解決]

react異常:Can’t perform a React state update on an unmounted component[已解決]

react異常:Can‘t perform a React state update on an unmounted component[已解決]

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.

原因:

解決方案:

componentWillUnmount() {
    this.setState = ()=>false;
}      

繼續閱讀