Skip to content

Commit 1b29b03

Browse files
committed
minor enhancement isRunning location in code
1 parent 240e1b6 commit 1b29b03

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

app/App.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ function MyTimer({ expiryTimestamp }) {
2323
<div style={{ fontSize: '100px' }}>
2424
<span>{days}</span>:<span>{hours}</span>:<span>{minutes}</span>:<span>{seconds}</span>
2525
</div>
26+
<p>{isRunning ? 'Running' : 'Not running'}</p>
2627
<button type="button" onClick={start}>Start</button>
2728
<button type="button" onClick={pause}>Pause</button>
2829
<button type="button" onClick={resume}>Resume</button>
@@ -37,7 +38,6 @@ function MyTimer({ expiryTimestamp }) {
3738
>
3839
Restart
3940
</button>
40-
<p>{isRunning ? 'Running' : 'Not running'}</p>
4141
</div>
4242
);
4343
}

readme.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ function MyTimer({ expiryTimestamp }) {
3737
minutes,
3838
hours,
3939
days,
40+
isRunning,
4041
start,
4142
pause,
4243
resume,
4344
restart,
44-
isRunning,
4545
} = useTimer({ expiryTimestamp, onExpire: () => console.warn('onExpire called') });
4646

4747

@@ -52,6 +52,7 @@ function MyTimer({ expiryTimestamp }) {
5252
<div style={{fontSize: '100px'}}>
5353
<span>{days}</span>:<span>{hours}</span>:<span>{minutes}</span>:<span>{seconds}</span>
5454
</div>
55+
<p>{isRunning ? 'Running' : 'Not running'}</p>
5556
<button onClick={start}>Start</button>
5657
<button onClick={pause}>Pause</button>
5758
<button onClick={resume}>Resume</button>
@@ -61,7 +62,6 @@ function MyTimer({ expiryTimestamp }) {
6162
time.setSeconds(time.getSeconds() + 300);
6263
restart(time)
6364
}}>Restart</button>
64-
<p>{isRunning ? 'Running' : 'Not running'}</p>
6565
</div>
6666
);
6767
}
@@ -92,11 +92,11 @@ export default function App() {
9292
| minutes | number | minutes value |
9393
| hours | number | hours value |
9494
| days | number | days value |
95+
| isRunning | boolean | flag to indicate if timer is running or not |
9596
| pause | function | function to be called to pause timer |
9697
| start | function | function if called after pause the timer will continue based on original expiryTimestamp |
9798
| resume | function | function if called after pause the timer will continue countdown from last paused state |
9899
| restart | function | function to restart timer with new expiryTimestamp |
99-
| isRunning | boolean | flag to indicate if timer is running or not |
100100

101101

102102
---
@@ -115,10 +115,10 @@ function MyStopwatch() {
115115
minutes,
116116
hours,
117117
days,
118+
isRunning,
118119
start,
119120
pause,
120121
reset,
121-
isRunning,
122122
} = useStopwatch({ autoStart: true });
123123

124124

@@ -129,10 +129,10 @@ function MyStopwatch() {
129129
<div style={{fontSize: '100px'}}>
130130
<span>{days}</span>:<span>{hours}</span>:<span>{minutes}</span>:<span>{seconds}</span>
131131
</div>
132+
<p>{isRunning ? 'Running' : 'Not running'}</p>
132133
<button onClick={start}>Start</button>
133134
<button onClick={pause}>Pause</button>
134135
<button onClick={reset}>Reset</button>
135-
<p>{isRunning ? 'Running' : 'Not running'}</p>
136136
</div>
137137
);
138138
}
@@ -160,10 +160,10 @@ export default function App() {
160160
| minutes | number | minutes value |
161161
| hours | number | hours value |
162162
| days | number | days value |
163+
| isRunning | boolean | flag to indicate if stopwatch is running or not |
163164
| start | function | function to be called to start/resume stopwatch |
164165
| pause | function | function to be called to pause stopwatch |
165166
| reset | function | function to be called to reset stopwatch to 0:0:0:0 |
166-
| isRunning | boolean | flag to indicate if stopwatch is running or not |
167167

168168

169169
---

0 commit comments

Comments
 (0)