Guest User

Untitled

a guest
Nov 18th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. handleTimer(evt){
  2. const id=evt.target.id;
  3. clearInterval(this.Interval)
  4. this.Interval=setInterval(() => {
  5. let timer=this.state.timer;
  6. if(timer > 0){
  7. this.setState({
  8. timer: this.state.timer - 1
  9. })
  10. }else if(id==="reset"){
  11. clearInterval(this.Interval);
  12. this.setState((state) => ({
  13. session: 25, timer:1500, break:5, isRunning:false}))
  14. }
  15. else{
  16. clearInterval(this.Interval)}
  17. },1000)}
Add Comment
Please, Sign In to add comment