Skip to content

Open-source status page, incident response and uptime monitoring

fix: hydration errors (#1507)

Maximilian Kaskecc877dae47c2
diff --git a/apps/status-page/src/app/(public)/client.tsx b/apps/status-page/src/app/(public)/client.tsx
index e7465b25d..19eb18bc5 100644
--- a/apps/status-page/src/app/(public)/client.tsx
+++ b/apps/status-page/src/app/(public)/client.tsx
@@ -141,7 +141,7 @@ export function Client() {
data-active={k === t}
data-slot="theme-card"
data-theme={k}
- className="relative h-40 cursor-pointer overflow-hidden rounded-md border outline-none transition-all focus:outline-ring/50 focus:ring-2 focus:ring-ring/50 data-[active=true]:border-ring data-[active=true]:outline-[3px] data-[active=true]:outline-ring/50"
+ className="relative h-40 cursor-pointer overflow-hidden rounded-md border border-border outline-none transition-all focus:outline-ring/50 focus:ring-2 focus:ring-ring/50 data-[active=true]:border-ring data-[active=true]:outline-[3px] data-[active=true]:outline-ring/50"
onClick={() => setSearchParams({ t: k })}
role="button"
tabIndex={0}
@@ -165,7 +165,7 @@ export function Client() {
</div>
<div className="flex items-start justify-between gap-2">
<div className="space-y-0.5 truncate">
- <div className="font-medium text-foreground text-sm leading-none truncate">
+ <div className="truncate font-medium text-foreground text-sm leading-none">
{theme.name}
</div>
<div className="font-mono text-xs">
diff --git a/apps/status-page/src/components/nav/footer.tsx b/apps/status-page/src/components/nav/footer.tsx
index ad5c6d1bd..4c27d06db 100644
--- a/apps/status-page/src/components/nav/footer.tsx
+++ b/apps/status-page/src/components/nav/footer.tsx
@@ -3,19 +3,26 @@
import { Link } from "@/components/common/link";
import { TimestampHoverCard } from "@/components/content/timestamp-hover-card";
import { ThemeDropdown } from "@/components/themes/theme-dropdown";
+import { Skeleton } from "@/components/ui/skeleton";
import { useTRPC } from "@/lib/trpc/client";
import { useQuery } from "@tanstack/react-query";
import { Clock } from "lucide-react";
import { useParams } from "next/navigation";
+import { useEffect, useState } from "react";
export function Footer(props: React.ComponentProps<"footer">) {
const { domain } = useParams<{ domain: string }>();
+ const [isMounted, setIsMounted] = useState(false);
const trpc = useTRPC();
const { data: page, dataUpdatedAt } = useQuery(
trpc.statusPage.get.queryOptions({ slug: domain }),
);
const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
+ useEffect(() => {
+ setIsMounted(true);
+ }, []);
+
if (!page) return null;
return (
@@ -40,8 +47,14 @@ export function Footer(props: React.ComponentProps<"footer">) {
align="end"
className="flex items-center gap-1.5 text-muted-foreground/70"
>
- <Clock className="size-3" />
- <span className="font-mono text-xs">{timezone}</span>
+ {isMounted ? (
+ <>
+ <Clock className="size-3" />
+ <span className="font-mono text-xs">{timezone}</span>
+ </>
+ ) : (
+ <Skeleton className="h-4 w-28" />
+ )}
</TimestampHoverCard>
<ThemeDropdown />
</div>
diff --git a/apps/status-page/src/components/themes/theme-select.tsx b/apps/status-page/src/components/themes/theme-select.tsx
index 30ebd2da1..ec26daa63 100644
--- a/apps/status-page/src/components/themes/theme-select.tsx
+++ b/apps/status-page/src/components/themes/theme-select.tsx
@@ -10,6 +10,7 @@ import {
SelectTrigger,
SelectValue,
} from "@/components/ui/select";
+import { Skeleton } from "@/components/ui/skeleton";
import { cn } from "@/lib/utils";
import { Laptop, Moon, Sun } from "lucide-react";
import { useState } from "react";
@@ -26,21 +27,21 @@ export function ThemeSelect({
setMounted(true);
}, []);
- // NOTE: hydration error if we don't do this
if (!mounted) {
- return (
- <Select>
- <SelectTrigger className={cn("w-[180px]", className)} {...props}>
- <SelectValue placeholder="Select theme" />
- </SelectTrigger>
- </Select>
- );
+ return <Skeleton className="h-9 rounded-md border border-border" />;
}
return (
<Select value={theme} onValueChange={setTheme}>
- <SelectTrigger className={cn("w-[180px]", className)} {...props}>
- <SelectValue defaultValue={theme} placeholder="Select theme" />
+ <SelectTrigger
+ className={cn("min-w-[110px] max-w-[110px]", className)}
+ {...props}
+ >
+ <SelectValue
+ className="w-full"
+ defaultValue={theme}
+ placeholder="Select theme"
+ />
</SelectTrigger>
<SelectContent>
<SelectItem value="light">