File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ React timer hook is a custom [react hook](https://reactjs.org/docs/hooks-intro.h
44
551 . ` useTimer ` : Timers (countdown timer)
662 . ` useStopwatch ` : Stopwatch (count up timer)
7- 3 . ` useTime ` : Time (return current time)
7+ 3 . ` useTime ` : Time (return current time)
88
99
1010#### Note:
@@ -39,7 +39,8 @@ function MyTimer({ expiryTimestamp }) {
3939 days ,
4040 start ,
4141 pause ,
42- resume
42+ resume ,
43+ restart ,
4344 } = useTimer ({ expiryTimestamp, onExpire : () => console .warn (' onExpire called' ) });
4445
4546
@@ -53,6 +54,12 @@ function MyTimer({ expiryTimestamp }) {
5354 < button onClick= {start}> Start< / button>
5455 < button onClick= {pause}> Pause< / button>
5556 < button onClick= {resume}> Resume< / button>
57+ < button onClick= {() => {
58+ // Restarts to 5 minutes timer
59+ var t = new Date ();
60+ t .setSeconds (t .getSeconds () + 300 );
61+ restart (t)
62+ }}> restart< / button>
5663 < / div>
5764 );
5865}
@@ -86,6 +93,7 @@ export default function App() {
8693| pause | function | function to be called to pause timer |
8794| start | function | function if called after pause the timer will continue based on original expiryTimestamp |
8895| resume | function | function if called after pause the timer will continue countdown from last paused state |
96+ | restart | function | function to restart timer with new expiryTimestamp |
8997
9098
9199---
You can’t perform that action at this time.
0 commit comments