brackt/app/hooks/useHasMounted.ts
Chris Parsons 8a9cffd076
All checks were successful
🚀 Deploy / 🧪 Test (pull_request) Successful in 4m0s
🚀 Deploy / ʦ🔍 Typecheck & Lint (pull_request) Successful in 1m26s
🚀 Deploy / 🐳 Build (pull_request) Has been skipped
🚀 Deploy / 🚀 Deploy (pull_request) Has been skipped
Fix SSR/hydration timezone flip in event date and time display
UTC timestamps rendered with date-fns format() or toLocaleTimeString() use the
runtime's local timezone, causing the server (UTC) and client (PDT) to produce
different output. suppressHydrationWarning was hiding the mismatch but the
visual time-flip was still visible on load.

- Add useHasMounted hook (useSyncExternalStore-based, no extra render cycle)
- Gate UTC timestamp formatting behind isMounted in EventSchedule and
  UpcomingCalendarPanel; SSR always renders the stable YYYY-MM-DD eventDate string
- Fix formatEventDate in date-utils.ts (and EventSchedule private copy) to parse
  YYYY-MM-DD as local midnight instead of UTC midnight, fixing the off-by-one day
  bug for UTC-negative users across all callers

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-16 22:47:22 -07:00

7 lines
194 B
TypeScript

import { useSyncExternalStore } from "react";
const subscribe = () => () => {};
export function useHasMounted(): boolean {
return useSyncExternalStore(subscribe, () => true, () => false);
}