MCPcopy Create free account
hub / github.com/amrlabib/react-timer-hook / UseTimerDemo

Function UseTimerDemo

demo/components/UseTimerDemo.tsx:6–39  ·  view source on GitHub ↗
({ expiryTimestamp, interval }: { expiryTimestamp: Date, interval: number})

Source from the content-addressed store, hash-verified

4import Button from './Button';
5
6export default function UseTimerDemo({ expiryTimestamp, interval }: { expiryTimestamp: Date, interval: number}) {
7 const {
8 milliseconds,
9 seconds,
10 minutes,
11 hours,
12 days,
13 start,
14 pause,
15 resume,
16 restart,
17 } = useTimer({ expiryTimestamp, onExpire: () => console.warn('onExpire called'), interval });
18
19 return (
20 <div>
21 <h2>UseTimer Demo</h2>
22 <TimerStyled milliseconds={milliseconds} seconds={seconds} minutes={minutes} hours={hours} days={days} enableMilliseconds={interval < 1000} />
23 <Button type="button" onClick={start}>Start</Button>
24 <Button type="button" onClick={pause}>Pause</Button>
25 <Button type="button" onClick={resume}>Resume</Button>
26 <Button
27 type="button"
28 onClick={() => {
29 // Restarts to 10 minutes timer
30 const time = new Date();
31 time.setSeconds(time.getSeconds() + 600);
32 restart(time);
33 }}
34 >
35 Restart
36 </Button>
37 </div>
38 );
39}

Callers

nothing calls this directly

Calls 1

useTimerFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…