diff --git a/client/coral-admin/src/components/CountdownTimer.js b/client/coral-admin/src/components/CountdownTimer.js index 3eaa6d305..aba4d0b5a 100644 --- a/client/coral-admin/src/components/CountdownTimer.js +++ b/client/coral-admin/src/components/CountdownTimer.js @@ -31,16 +31,20 @@ class CountdownTimer extends React.Component { } componentWillMount () { - setInterval(() => { // the countdown timer + this.interval = setInterval(() => { // the countdown timer let nextCount = this.state.secondsUntilRefresh - 1; if (nextCount < 0) { nextCount = refreshIntervalSeconds; - this.props.handleTimeout(); + return this.props.handleTimeout(); } this.setState({secondsUntilRefresh: nextCount}); }, 1000); } + componentWillUnmount () { + window.clearInterval(this.interval); + } + formatTime = () => { const minutes = Math.floor(this.state.secondsUntilRefresh / 60); let seconds = (this.state.secondsUntilRefresh % 60).toString();