-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.tsx
48 lines (45 loc) · 1.27 KB
/
App.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import { useStopwatch } from "./hooks";
const App = () => {
const {
current,
remainingTime,
currentDays,
currentHours,
currentMinutes,
currentSeconds,
elapsedSeconds,
remainingSeconds,
isPaused,
isOver,
pause,
play,
reset,
togglePause,
} = useStopwatch({
endTime: "00:00:00:10",
startPaused: true,
separator: "-",
onFinish: () => console.log("Stopwatch ended"),
});
return (
<div>
<p>Stopwatch value: {current.withLeadingZero}</p>
<p>Stopwatch value: {current.withoutLeadingZero}</p>
<p>Remaining time: {remainingTime.withLeadingZero}</p>
<p>Remaining time: {remainingTime.withoutLeadingZero}</p>
<p>Days: {currentDays}</p>
<p>Hours: {currentHours}</p>
<p>Minutes: {currentMinutes}</p>
<p>Seconds: {currentSeconds}</p>
<p>Elapsed seconds: {elapsedSeconds}</p>
<p>Remaining seconds: {remainingSeconds}</p>
<p>Is the counter paused? {isPaused ? "Yes" : "No"}</p>
<p>Has the counter over? {isOver ? "Yes" : "No"}</p>
<button onClick={pause}>Pause</button>
<button onClick={play}>Play</button>
<button onClick={reset}>Reset</button>
<button onClick={togglePause}>Toggle Pause</button>
</div>
);
};
export default App;