Skip to content

Fix bill date hydration mismatch with UTC formatting#26

Merged
mikaalnaik merged 1 commit into
mainfrom
mikaal/bills-react-error
Jul 7, 2026
Merged

Fix bill date hydration mismatch with UTC formatting#26
mikaalnaik merged 1 commit into
mainfrom
mikaal/bills-react-error

Conversation

@mikaalnaik

Copy link
Copy Markdown
Contributor

Summary

Fixes a React hydration mismatch caused by bill date formatting.

Bill stage dates are calendar dates stored as UTC midnight (e.g. 2025-06-05T00:00:00.000Z). Formatting them with dayjs(...).format(...) uses the runtime's local timezone, so the server (UTC) and client (user's local tz) could render different days — triggering a hydration mismatch.

Changes

  • Add src/app/bills/utils/format-date.ts with a shared formatBillDate helper that formats in UTC (dayjs.utc), deterministic across server and client, and handles null/invalid values by returning "N/A".
  • Use formatBillDate in BillCard and BillMetadata, removing the duplicated inline dayjs formatting.

🤖 Generated with Claude Code

Bill stage dates are calendar dates stored as UTC midnight. Formatting
them in the runtime's local timezone made SSR (UTC) and client hydration
(local tz) disagree on the day, triggering a React hydration mismatch.

Add a shared formatBillDate helper that formats in UTC deterministically,
and use it in BillCard and BillMetadata.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@mikaalnaik mikaalnaik merged commit fef8352 into main Jul 7, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant