Unmounting A Component With A Setinterval In React
I'm trying to unmount a component with a setInterval. This is based on the answer here: Component: class ImageSlider extends React.Component { constructor(props) { super(pro
setInterval
returns an in interval Id that you can use in clearInterval
.
Something like this should work:
this.myInterval = setInterval(this.changeActiveMedia.bind(this), 5000)
then in componentWillUnmount:
clearInterval(this.myInterval);
Post a Comment for "Unmounting A Component With A Setinterval In React"