@@ -41,6 +41,7 @@ function MyTimer({ expiryTimestamp }) {
41
41
pause ,
42
42
resume ,
43
43
restart ,
44
+ isRunning ,
44
45
} = useTimer ({ expiryTimestamp, onExpire : () => console .warn (' onExpire called' ) });
45
46
46
47
@@ -60,6 +61,7 @@ function MyTimer({ expiryTimestamp }) {
60
61
time .setSeconds (time .getSeconds () + 300 );
61
62
restart (time)
62
63
}}> Restart< / button>
64
+ < p> {isRunning ? ' Running' : ' Not running' }< / p>
63
65
< / div>
64
66
);
65
67
}
@@ -94,6 +96,7 @@ export default function App() {
94
96
| start | function | function if called after pause the timer will continue based on original expiryTimestamp |
95
97
| resume | function | function if called after pause the timer will continue countdown from last paused state |
96
98
| restart | function | function to restart timer with new expiryTimestamp |
99
+ | isRunning | boolean | flag to indicate if timer is running or not |
97
100
98
101
99
102
---
@@ -115,6 +118,7 @@ function MyStopwatch() {
115
118
start ,
116
119
pause ,
117
120
reset ,
121
+ isRunning ,
118
122
} = useStopwatch ({ autoStart: true });
119
123
120
124
@@ -128,6 +132,7 @@ function MyStopwatch() {
128
132
< button onClick= {start}> Start< / button>
129
133
< button onClick= {pause}> Pause< / button>
130
134
< button onClick= {reset}> Reset< / button>
135
+ < p> {isRunning ? ' Running' : ' Not running' }< / p>
131
136
< / div>
132
137
);
133
138
}
@@ -158,6 +163,7 @@ export default function App() {
158
163
| start | function | function to be called to start/resume stopwatch |
159
164
| pause | function | function to be called to pause stopwatch |
160
165
| 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 |
161
167
162
168
163
169
---
0 commit comments