fix: resolve hydration mismatch and NaN rendering errors
Some checks failed
Dev Deployment (Zero Downtime) / deploy-dev (push) Failing after 9m53s
Some checks failed
Dev Deployment (Zero Downtime) / deploy-dev (push) Failing after 9m53s
Added suppressHydrationWarning to html tag and implemented safe date/number handling in project and reading components.
This commit is contained in:
@@ -137,12 +137,12 @@ const CurrentlyReading = () => {
|
||||
<div className="space-y-2">
|
||||
<div className="flex items-center justify-between text-xs text-stone-600 dark:text-stone-400">
|
||||
<span>{t("progress")}</span>
|
||||
<span className="font-semibold">{book.progress}%</span>
|
||||
<span className="font-semibold">{isNaN(book.progress) ? 0 : book.progress}%</span>
|
||||
</div>
|
||||
<div className="relative h-2 bg-white/50 dark:bg-stone-700 rounded-full overflow-hidden border border-white/70 dark:border-stone-600">
|
||||
<motion.div
|
||||
initial={{ width: 0 }}
|
||||
animate={{ width: `${book.progress}%` }}
|
||||
animate={{ width: `${isNaN(book.progress) ? 0 : book.progress}%` }}
|
||||
transition={{ duration: 1, delay: 0.3 + index * 0.1, ease: "easeOut" }}
|
||||
className="absolute left-0 top-0 h-full bg-gradient-to-r from-liquid-lavender via-liquid-pink to-liquid-rose rounded-full shadow-sm"
|
||||
/>
|
||||
|
||||
@@ -189,7 +189,12 @@ const Projects = () => {
|
||||
</h3>
|
||||
<div className="flex items-center space-x-2 text-stone-400 text-xs font-mono bg-white/50 px-2 py-1 rounded border border-stone-100">
|
||||
<Calendar size={12} />
|
||||
<span>{new Date(project.date).getFullYear()}</span>
|
||||
<span>
|
||||
{(() => {
|
||||
const d = new Date(project.date);
|
||||
return isNaN(d.getTime()) ? project.date : d.getFullYear();
|
||||
})()}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user