This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div className="App"> | |
<header className="App-header"> | |
<h2>Timers completed: {completed}</h2> | |
<h2>{timer.value}</h2> | |
<div> | |
<Button onClick={timer.start}>Start</Button> | |
<Button onClick={timer.stop}>Stop</Button> | |
</div> | |
<div> | |
<Button onClick={timer.skip}>Skip</Button> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const length = 10 * 1000 * 60; | |
const App: React.FC = () => { | |
const timer = useTimer({ length }); | |
return ( | |
<div className="App"> | |
<h2>{timer.value}</h2> | |
<div> | |
<Button onClick={timer.start}>Start</Button> | |
<Button onClick={timer.stop}>Stop</Button> | |
<Button onClick={timer.skip}>Skip</Button> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useState, useRef } from "react"; | |
interface Props { | |
length: number; | |
onComplete?: () => void; | |
} | |
const tick = 200; | |
const format = (date: number): string => { |