Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can only update a mounted or mounting component. This usually means you called setState, replaceState, or forceUpdate on an unmounted component. This is a no-op. Please check the code for the AnimateNumber component. #8

Open
marlti7 opened this issue Jun 21, 2017 · 4 comments
Labels

Comments

@marlti7
Copy link

marlti7 commented Jun 21, 2017

When I go back to a page,find this problem

@marlti7
Copy link
Author

marlti7 commented Jun 22, 2017

I found a solution, when componentWillUnmount need clearout Timer

@wkh237 wkh237 added the bug label Jun 22, 2017
@uglyspoon
Copy link

@marlti7
by add

 componentWillUnmount () {
    clearTimeout(Timer);
  }

not work for me

@uglyspoon
Copy link

find a way to fix this bug , this bug because the Timer won't unmount when your component unmounts.
so set clearTimeout when componentWillUnmount();
code like this :

startAnimate() {
  this.timer = Timer.setTimeout(() => {
    console.log('I do not leak!');
  }, 500);
}

componentWillUnmount() {
  clearTimeout(this.timer);
}

happy coding !

@marquesm91
Copy link

marquesm91 commented May 18, 2018

@uglyspoon I just add it on the bottom of AnimatedNumber class

componentWillUnmount () {
  clearTimeout(Timer);
}

And works for me. Now, when I go to another screen I am fine and the warning doesn't show anymore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants