0

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.

const handleAsyncActions = async () => {
    await this.props.loginSuccess({ login: { data: { ...data } } });
    await localStorage.setItem('oauth', b64EncodeUnicode(JSON.stringify(data)));
    await this.props.history.push('/dashboard');
};
handleAsyncActions();

How to solve this problem in best way.

Sagar
  • 4,473
  • 3
  • 32
  • 37
  • 1
    "To fix, cancel all subscriptions and asynchronous tasks in the `componentWillUnmount` method"...that's how you solve the problem – Leo Jul 20 '18 at 06:27
  • `cancel all asynchronous tasks in componentWillUnmount method`. This include clearTimeout, clearInterval, or anything that you use that might update the state. – Jackyef Jul 20 '18 at 06:28
  • I have made asynchronous actions or process into synchronous way. – Sagar Jul 20 '18 at 06:32
  • Possible duplicate of [React warning about setState in unmounted component](https://stackoverflow.com/questions/50029468/react-warning-about-setstate-in-unmounted-component) – fkoessler Sep 12 '18 at 12:24

0 Answers0