react-native-animate-number
react-native-animate-number copied to clipboard
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.
When I go back to a page,find this problem
I found a solution, when componentWillUnmount need clearout Timer
@marlti7 by add
componentWillUnmount () {
clearTimeout(Timer);
}
not work for me
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 !
@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.