From 29ddf7972b0047fb12dfb227f678379f6b724c37 Mon Sep 17 00:00:00 2001 From: "colin-codegen[bot]" <137733214+colin-codegen[bot]@users.noreply.github.com> Date: Mon, 21 Aug 2023 19:56:38 +0000 Subject: [PATCH] Add new Stopwatch component --- src/components/ui/Stopwatch/Stopwatch.tsx | 23 +++++++++++++++++++++++ src/pages/_app.tsx | 3 +++ 2 files changed, 26 insertions(+) create mode 100644 src/components/ui/Stopwatch/Stopwatch.tsx diff --git a/src/components/ui/Stopwatch/Stopwatch.tsx b/src/components/ui/Stopwatch/Stopwatch.tsx new file mode 100644 index 0000000..e183ad6 --- /dev/null +++ b/src/components/ui/Stopwatch/Stopwatch.tsx @@ -0,0 +1,23 @@ +// src/components/ui/Stopwatch/Stopwatch.tsx + +import { useEffect, useState } from 'react'; + +const Stopwatch = () => { + const [seconds, setSeconds] = useState(0); + + useEffect(() => { + const interval = setInterval(() => { + setSeconds(seconds => seconds + 1); + }, 1000); + + return () => clearInterval(interval); + }, []); + + return ( +