File tree Expand file tree Collapse file tree 2 files changed +20
-13
lines changed Expand file tree Collapse file tree 2 files changed +20
-13
lines changed Original file line number Diff line number Diff line change 66 "rules": {
77 "react-hooks/rules-of-hooks": "error",
88 "react-hooks/exhaustive-deps": "warn",
9+ "react/jsx-filename-extension": 0,
910 "no-unused-expressions": [ 2,{
1011 "allowShortCircuit": true,
1112 }],
Original file line number Diff line number Diff line change 11import React from 'react' ;
22import { useTimer } from '../src/index' ;
33
4+
45function MyTimer ( { expiryTimestamp } ) {
56 const {
67 seconds,
@@ -10,32 +11,37 @@ function MyTimer({ expiryTimestamp }) {
1011 start,
1112 pause,
1213 resume,
13- restart
14+ restart,
1415 } = useTimer ( { expiryTimestamp, onExpire : ( ) => console . warn ( 'onExpire called' ) } ) ;
1516
1617
1718 return (
18- < div style = { { textAlign : 'center' } } >
19+ < div style = { { textAlign : 'center' } } >
1920 < h1 > react-timer-hook </ h1 >
2021 < p > Timer Demo</ p >
21- < div style = { { fontSize : '100px' } } >
22+ < div style = { { fontSize : '100px' } } >
2223 < span > { days } </ span > :< span > { hours } </ span > :< span > { minutes } </ span > :< span > { seconds } </ span >
2324 </ div >
24- < button onClick = { start } > Start</ button >
25- < button onClick = { pause } > Pause</ button >
26- < button onClick = { resume } > Resume</ button >
27- < button onClick = { ( ) => {
28- // Restarts to 5 minutes timer
29- var t = new Date ( ) ;
30- t . setSeconds ( t . getSeconds ( ) + 300 ) ;
31- restart ( t )
32- } } > restart</ button >
25+ < button type = "button" onClick = { start } > Start</ button >
26+ < button type = "button" onClick = { pause } > Pause</ button >
27+ < button type = "button" onClick = { resume } > Resume</ button >
28+ < button
29+ type = "button"
30+ onClick = { ( ) => {
31+ // Restarts to 5 minutes timer
32+ const t = new Date ( ) ;
33+ t . setSeconds ( t . getSeconds ( ) + 300 ) ;
34+ restart ( t ) ;
35+ } }
36+ >
37+ Restart
38+ </ button >
3339 </ div >
3440 ) ;
3541}
3642
3743export default function App ( ) {
38- var t = new Date ( ) ;
44+ const t = new Date ( ) ;
3945 t . setSeconds ( t . getSeconds ( ) + 600 ) ; // 10 minutes timer
4046 return (
4147 < div >
You can’t perform that action at this time.
0 commit comments