I have a setInterval
function with no clearInterval
, it is for an experimental glitch effect page that changes the background from time to time quite randomly.
My question is, would this cause a memory leak? or is there a way to improve it? that is, is there a way to make the interval run forever just as it is now, but without causing a memory leak? Right now I feel like the page is running very slow because of that.
This is my code (React JS)
imageTimerHandler() {
this.setState({
interval: setInterval(() => {
this.randomGlitchZoomHandler();
this.createGlitchRows();
let newSeconds = this.state.seconds + .1;
this.setSeconds(newSeconds);
this.selectImageHandler(newSeconds);
}, 100),
});
}