Skip to content

Commit a34e541

Browse files
committed
fix: build
1 parent 6f0cb9a commit a34e541

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

app/page.tsx

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,24 @@ import FlipClock from "../components/FlipClock";
55
import { DatePicker } from "../components/DatePicker";
66

77
export default function Home() {
8-
const [targetDate, setTargetDate] = useState(
9-
new Date(localStorage.getItem("targetDate") as string) ??
10-
new Date("2025-01-01")
11-
);
8+
const [targetDate, setTargetDate] = useState(new Date("2025-01-01"));
9+
const [isInitialized, setIsInitialized] = useState(false);
10+
11+
// Retrieve target date from localStorage after component mounts
12+
useEffect(() => {
13+
const storedDate = localStorage.getItem("targetDate");
14+
if (storedDate) {
15+
setTargetDate(new Date(storedDate));
16+
}
17+
setIsInitialized(true); // Indicate that initialization is complete
18+
}, []);
1219

13-
// set target date to local storage
20+
// Update localStorage whenever targetDate changes (after initialization)
1421
useEffect(() => {
15-
localStorage.setItem("targetDate", targetDate.toString());
16-
}, [targetDate]);
22+
if (isInitialized) {
23+
localStorage.setItem("targetDate", targetDate.toString());
24+
}
25+
}, [targetDate, isInitialized]);
1726

1827
return (
1928
<main className="flex flex-col items-center justify-center h-screen gap-20">

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
services:
22
nextjs:
33
image: node:18-alpine
4-
container_name: timer.ayushchugh.com
4+
container_name: fliptimer.ayushchugh.com
55
working_dir: /app
66
ports:
77
- "3002:3000"

0 commit comments

Comments
 (0)