Skip to content

Commit c4b8370

Browse files
committed
handle less than a second timer inside handleExtraMilliSeconds
1 parent c933ef9 commit c4b8370

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/useTimer.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,14 @@ export default function useTimer(settings) {
5959
function handleExtraMilliSeconds(secondsValue, extraMilliSeconds) {
6060
setIsRunning(true);
6161
intervalRef.current = setTimeout(() => {
62-
intervalRef.current = undefined;
63-
setSeconds(Time.getSecondsFromExpiry(expiryTimestamp));
64-
start();
62+
const currentSeconds = Time.getSecondsFromExpiry(expiryTimestamp);
63+
setSeconds(currentSeconds);
64+
if (currentSeconds <= 0) {
65+
handleExpire();
66+
} else {
67+
intervalRef.current = undefined;
68+
start();
69+
}
6570
}, extraMilliSeconds);
6671
}
6772

0 commit comments

Comments
 (0)