Skip to content

Commit

Permalink
fix(dashboard): resolve hydration error by using consistent date form…
Browse files Browse the repository at this point in the history
…atting

Replace `toLocaleDateString()` with `date-fns` to ensure consistent date formatting between server and client. This prevents hydration mismatches caused by differing time zones or locale settings, ensuring stable rendering across environments.
  • Loading branch information
unrenamed committed Oct 14, 2024
1 parent 5284511 commit 853ea2a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions apps/dashboard/app/(app)/audit/[bucket]/row.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Badge } from "@/components/ui/badge";
import { Code } from "@/components/ui/code";
import { TableCell, TableRow } from "@/components/ui/table";
import { cn } from "@/lib/utils";
import { format } from "date-fns";
import { ChevronDown, KeySquare, Minus } from "lucide-react";
import { useState } from "react";

Expand Down Expand Up @@ -85,10 +86,10 @@ export const Row: React.FC<Props> = ({ auditLog, user }) => {
<TableCell>
<div className="flex items-center gap-2">
<span className="text-sm text-content">
{new Date(auditLog.time).toLocaleDateString()}
{format(new Date(auditLog.time), 'dd/MM/yyyy')}
</span>
<span className="text-xs text-content-subtle">
{new Date(auditLog.time).toLocaleTimeString()}
{format(new Date(auditLog.time), 'dd/MM/yyyy')}
</span>
</div>
</TableCell>
Expand Down

0 comments on commit 853ea2a

Please sign in to comment.