aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorasketonim <anton.dubik33@gmail.com>2020-01-05 00:40:40 +0300
committerasketonim <anton.dubik33@gmail.com>2020-01-05 00:40:40 +0300
commita179118bfa2f7af306893895161adf9fb9bd1897 (patch)
tree3dfb4a19f908cbb5faa5abf23f1176c991a9e463 /src
parent347f9d604044236830020f232fab3733c628720f (diff)
downloadchrono-cube-ui-a179118bfa2f7af306893895161adf9fb9bd1897.tar.gz
Fix timer behavior and initial time value
Diffstat (limited to 'src')
-rw-r--r--src/components/Timer/Timer.js8
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);