Skip to content
This repository was archived by the owner on Aug 2, 2025. It is now read-only.

Commit 0bfa927

Browse files
committed
fix: move useEffect before conditional
1 parent 0b9b0c9 commit 0bfa927

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

apps/client/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "client",
3-
"version": "1.5.2-beta",
3+
"version": "1.5.3-beta",
44
"scripts": {
55
"dev": "npm-run-all --parallel dev:*",
66
"dev:run": "FORCE_COLOR=1 vite",

apps/client/src/routes/Main/Home/Countdown.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,22 @@ export default function Countdown({
3030
const nextPeriod =
3131
activeIndex && activeIndex > 0 ? dtt?.periods[activeIndex + 1] : undefined;
3232

33-
if (!nextPeriod) return null;
34-
3533
useEffect(() => {
34+
if (!nextPeriod) return;
35+
36+
const duration = DateTime.fromISO(nextPeriod.startTime).diffNow();
37+
3638
const timer = setInterval(() => {
3739
setCountdown(
38-
DateTime.fromISO(nextPeriod.startTime).diffNow().toFormat("hh:mm:ss")
40+
duration.milliseconds > 0 ? duration.toFormat("hh:mm:ss") : "Now"
3941
);
4042
}, 500);
4143

4244
return () => clearInterval(timer);
4345
});
4446

47+
if (!nextPeriod) return null;
48+
4549
return (
4650
<Skeleton isLoaded={isLoaded}>
4751
<Flex

0 commit comments

Comments
 (0)