From 5576e41ce0a5c798f51e4b9613ba3bed5ee0d559 Mon Sep 17 00:00:00 2001 From: denshooter Date: Sun, 15 Feb 2026 22:48:47 +0100 Subject: [PATCH] fix: resolve hydration mismatch and NaN rendering errors Added suppressHydrationWarning to html tag and implemented safe date/number handling in project and reading components. --- app/_ui/ProjectsPageClient.tsx | 7 ++++++- app/components/CurrentlyReading.tsx | 4 ++-- app/components/Projects.tsx | 7 ++++++- app/layout.tsx | 2 +- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/app/_ui/ProjectsPageClient.tsx b/app/_ui/ProjectsPageClient.tsx index a9982d3..b84c989 100644 --- a/app/_ui/ProjectsPageClient.tsx +++ b/app/_ui/ProjectsPageClient.tsx @@ -222,7 +222,12 @@ export default function ProjectsPageClient({
- {new Date(project.date).getFullYear()} + + {(() => { + const d = new Date(project.date); + return isNaN(d.getTime()) ? project.date : d.getFullYear(); + })()} +
diff --git a/app/components/CurrentlyReading.tsx b/app/components/CurrentlyReading.tsx index c03c8c7..36059ff 100644 --- a/app/components/CurrentlyReading.tsx +++ b/app/components/CurrentlyReading.tsx @@ -137,12 +137,12 @@ const CurrentlyReading = () => {
{t("progress")} - {book.progress}% + {isNaN(book.progress) ? 0 : book.progress}%
diff --git a/app/components/Projects.tsx b/app/components/Projects.tsx index 1a7f46e..a7ae43e 100644 --- a/app/components/Projects.tsx +++ b/app/components/Projects.tsx @@ -189,7 +189,12 @@ const Projects = () => {
- {new Date(project.date).getFullYear()} + + {(() => { + const d = new Date(project.date); + return isNaN(d.getTime()) ? project.date : d.getFullYear(); + })()} +
diff --git a/app/layout.tsx b/app/layout.tsx index ccef9b4..bf4b3c4 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -29,7 +29,7 @@ export default async function RootLayout({ const cookieStore = await cookies(); const locale = cookieStore.get("NEXT_LOCALE")?.value || "en"; return ( - +