Memory leak in pomodoro clock

I just finished my pomodoro clock with all tests passing. :grin:

I get this warning though that appear sometimes in my console

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.
in Pomodoro

I tried to add this line of code but hasn’t gone away

 componentWillUnmount() {

where decrementInterval is the setInterval timer I am using for the clock. Has anyone else got this warning?

I’m not sure but have you tried setting the Interval to a variable inside your component rather than the window object? Maybe in the constructor of the component?

Are you sure that every time you set and interval or timeout, you save that time and clear it at some point? Put some console.logs at your set and clear point and trace it out.

Actually even though my tests were all passing there was a bug were after starting the clock again from an initial pause the clock would double it’s counting down time. I think this is what the error was getting at. I did fix it though by putting a clearInterval statement at the beginning of my handle start/stop function.

Right, it sounds like the other interval was still running and then you added another so there were now two - hence the double speed. I think I had that problem when I build mine. But that’s a good example of what a memory leak is.