import React, { Component } from 'react'; import { Button, Container, Row, Col } from 'reactstrap'; import './Timer.css'; import logo from '../logo.svg'; class Timer extends Component { constructor(props) { super(props); this.defaultSeconds = 1500; this.defaultLogoSpin = 'App-logo-rotation'; this.state = { seconds: this.defaultSeconds, started: false, logoSpin: '' }; this.startTimer = this.startTimer.bind(this); this.stopTimer = this.stopTimer.bind(this); this.resetTimer = this.resetTimer.bind(this); } fmtMSS(s){return(s-(s%=60))/60+(9 ({ seconds: state.seconds -1 })); } startTimer() { this.setState({ started: true, logoSpin: this.defaultLogoSpin }); this.interval = setInterval(() => this.tick(), 1000); } stopTimer() { this.setState({ started: false, logoSpin: null }); clearInterval(this.interval); } resetTimer() { this.stopTimer(); this.setState({ seconds: this.defaultSeconds}); } render() { return (

{this.fmtMSS(this.state.seconds)}

); } } export default Timer;