diff options
-rw-r--r-- | src/components/Timer/Timer.js | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/components/Timer/Timer.js b/src/components/Timer/Timer.js index f840429..4712265 100644 --- a/src/components/Timer/Timer.js +++ b/src/components/Timer/Timer.js @@ -7,7 +7,7 @@ import { Typography } from '@material-ui/core'; const Timer = () => { const SPACE = 32; const maxCountdown = 15000; - const [time, setTime] = useState('00:15:00'); + const [time, setTime] = useState('00:00:00'); const [isRunning, setIsRunning] = useState(false); const [timer, setTimer] = useState(0); const [isCountdown, setIsCountdown] = useState(false); @@ -32,14 +32,14 @@ const Timer = () => { }; const handleKeyUp = event => { - clearInterval(timer); - if (event.keyCode === SPACE){ + if (event.keyCode === SPACE) { + clearInterval(timer); if (!isRunning) { startingTime = Date.now(); setIsRunning(true); setTimer(setInterval(() => setTime(convertTimeToString((Date.now() - startingTime))), 10)); } else { - + clearInterval(timer); setIsRunning(false); setIsCountdown(false); |