Skip to content

Commit 25dbf1d

Browse files
authored
Merge pull request #24 from amrlabib/readme-updates
Readme updates
2 parents a9d1ce3 + 456b2c6 commit 25dbf1d

File tree

7 files changed

+29
-23
lines changed

7 files changed

+29
-23
lines changed

.eslintrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
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
}],

.npmignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ build
55
!.eslintrc
66
yarn-error.log
77
dev-dist
8-
readme-images
98

109
*.js
1110
!dist/index.js

app/App.js

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from 'react';
22
import { useTimer } from '../src/index';
33

4+
45
function MyTimer({ expiryTimestamp }) {
56
const {
67
seconds,
@@ -10,36 +11,41 @@ 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 time = new Date();
33+
time.setSeconds(time.getSeconds() + 300);
34+
restart(time);
35+
}}
36+
>
37+
Restart
38+
</button>
3339
</div>
3440
);
3541
}
3642

3743
export default function App() {
38-
var t = new Date();
39-
t.setSeconds(t.getSeconds() + 600); // 10 minutes timer
44+
const time = new Date();
45+
time.setSeconds(time.getSeconds() + 600); // 10 minutes timer
4046
return (
4147
<div>
42-
<MyTimer expiryTimestamp={t} />
48+
<MyTimer expiryTimestamp={time} />
4349
</div>
4450
);
4551
}

readme-images/useStopwatch.gif

-380 KB
Binary file not shown.

readme-images/useTime.gif

-109 KB
Binary file not shown.

readme-images/useTimer.gif

-293 KB
Binary file not shown.

readme.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,20 +56,20 @@ function MyTimer({ expiryTimestamp }) {
5656
<button onClick={resume}>Resume</button>
5757
<button onClick={() => {
5858
// Restarts to 5 minutes timer
59-
var t = new Date();
60-
t.setSeconds(t.getSeconds() + 300);
61-
restart(t)
62-
}}>restart</button>
59+
const time = new Date();
60+
time.setSeconds(time.getSeconds() + 300);
61+
restart(time)
62+
}}>Restart</button>
6363
</div>
6464
);
6565
}
6666

6767
export default function App() {
68-
var t = new Date();
69-
t.setSeconds(t.getSeconds() + 600); // 10 minutes timer
68+
const time = new Date();
69+
time.setSeconds(time.getSeconds() + 600); // 10 minutes timer
7070
return (
7171
<div>
72-
<MyTimer expiryTimestamp={t} />
72+
<MyTimer expiryTimestamp={time} />
7373
</div>
7474
);
7575
}

0 commit comments

Comments
 (0)