Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript React Basics (retired) Component Lifecycle Making the Stopwatch Tick

why component will unmount function is declare in here?

why component will unmount function is declare in here?

1 Answer

Pedro Esteves
Pedro Esteves
13,125 Points

In this case it doesn't do anything, because we aren't removing the stopwatch from the virtual DOM. If we were we should use the unmount function in order to stop the setInterval function that would be taking up memory for no reason.