Skip to content

Commit ef8ec5f

Browse files
committed
fix: restore countdown state naming
1 parent 2cbc9ef commit ef8ec5f

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

components/Activity/Hackathon/Hero.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,30 +80,30 @@ const useCountdown = (countdownTo?: string) => {
8080

8181
return Number.isFinite(value) ? value : NaN;
8282
}, [countdownTo]);
83-
const [clientNow, setClientNow] = useState<number | null>(null);
83+
const [now, setNow] = useState<number | null>(null);
8484

8585
useEffect(() => {
8686
if (!Number.isFinite(target)) return;
8787

88-
setClientNow(Date.now());
88+
setNow(Date.now());
8989

90-
const timer = window.setInterval(() => setClientNow(Date.now()), 1000);
90+
const timer = window.setInterval(() => setNow(Date.now()), 1000);
9191

9292
return () => window.clearInterval(timer);
9393
}, [target]);
9494

9595
return useMemo(() => {
96-
if (!Number.isFinite(target) || clientNow === null) return ['--', '--', '--', '--'];
96+
if (!Number.isFinite(target) || now === null) return ['--', '--', '--', '--'];
9797

98-
const rest = Math.max(0, target - clientNow);
98+
const rest = Math.max(0, target - now);
9999
const totalSeconds = Math.floor(rest / 1000);
100100
const days = Math.floor(totalSeconds / 86400);
101101
const hours = Math.floor((totalSeconds % 86400) / 3600);
102102
const minutes = Math.floor((totalSeconds % 3600) / 60);
103103
const seconds = totalSeconds % 60;
104104

105105
return [days, hours, minutes, seconds].map(value => String(value).padStart(2, '0'));
106-
}, [clientNow, target]);
106+
}, [now, target]);
107107
};
108108

109109
const splitHeroTitle = (name: string, subtitle: string) => {

0 commit comments

Comments
 (0)