Skip to content

Commit 1202117

Browse files
committed
fix countdown dependency array
1 parent 788595b commit 1202117

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

components/CountDownAnim/index.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { useState, useEffect } from 'react';
88

99
const useCountdown = (targetDate) => {
1010
const calculateTimeLeft = () => {
11-
const difference = +new Date(targetDate) - +new Date();
11+
const difference = new Date(targetDate) - new Date();
1212
let timeLeft = {};
1313

1414
if (difference > 0) {
@@ -31,7 +31,7 @@ const useCountdown = (targetDate) => {
3131
}, 1000);
3232

3333
return () => clearTimeout(timer);
34-
});
34+
}, [timeLeft]);
3535

3636
return timeLeft;
3737
};

0 commit comments

Comments
 (0)