trails/apps/journal/app/components/ClientDate.tsx
Ullrich Schäfer 4403e22006
Remove useEffect flicker from ClientDate
Now that both server and client use the same locale from context,
the post-hydration useEffect that re-formatted with the browser's
OS locale was causing a visible flicker. Just render with the
context locale directly.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-29 11:48:01 +02:00

12 lines
357 B
TypeScript

import { useLocale } from "./LocaleContext";
/**
* Renders a date formatted with the server-detected locale,
* ensuring SSR and client output match (no hydration flicker).
*/
export function ClientDate({ iso }: { iso: string }) {
const locale = useLocale();
return (
<time dateTime={iso}>{new Date(iso).toLocaleDateString(locale)}</time>
);
}