Canceling setInterval in React

added by JavaScript Kicks
9/17/2018 7:50:55 AM

550 Views

Sometimes you need to run a command in an interval using window.setInterval. But if you don't stop the interval when the component using the setInterval is not stopped, it will continuously run using unnecessary resources. I will talk about how to handle setInterval in React Let's create a very "contrived" example that prints "hello world" every second in console.


0 comments