Tell us what’s happening:
Can anyone point out the mistakes in my handleClick function that controls the countdown.
- On clicking the play button more than once the speed of countdown also increases simultaneously.
- After the end of the Break session, the countdown isn’t going back to the counting the normal Session again.
Plz help !
handleClick(){
this.setState({
running : true
})
setInterval(function(){
if(this.state.running ){
if(this.state.seconds>0){
this.setState({
seconds : this.state.seconds - 1
})
}
if(this.state.seconds == 0){
if(this.state.minutes == 0){
this.setState({
timerTitle: 'Break',
minutes : this.state.breakMinutes,
seconds : 0
})
if(this.state.seconds>0){
this.setState({
seconds : this.state.seconds - 1
})
}
if(this.state.seconds == 0){
if(this.state.breakMinutes == 0){
this.setState({
timerTitle: 'Session',
minutes : this.state.sessionMinutes,
seconds : 0
})
this.handleClick;
}
else{
this.setState({
minutes : this.state.minutes - 1,
seconds : 59
})
}
}
}
else{
this.setState({
minutes : this.state.minutes - 1,
seconds : 59
})
}
}
}
}.bind(this), 1000)
}
Your code so far
The code so far : https://codepen.io/corpsist/pen/bGEGboZ
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:77.0) Gecko/20100101 Firefox/77.0.
Challenge: Build a Pomodoro Clock
Link to the challenge:
https://www.freecodecamp.org/learn/front-end-libraries/front-end-libraries-projects/build-a-pomodoro-clock

