({ expiryTimestamp, interval }: { expiryTimestamp: Date, interval: number})
| 4 | import Button from './Button'; |
| 5 | |
| 6 | export 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 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…