Skip to content

Commit

Permalink
date hydrate error 해결 (24.01.02)
Browse files Browse the repository at this point in the history
date hydrate error 해결 (24.01.02)
  • Loading branch information
seoko97 authored Jan 2, 2024
2 parents 2517514 + bcf70d2 commit 73877da
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/components/ui/core/DateTime/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from "react";
import React, { useState } from "react";

import { dateTimeParser } from "@utils/dateTimeParser";

Expand All @@ -8,7 +8,13 @@ interface IProps {
}

const DateTime = ({ date, className }: IProps) => {
return <span className={className}>{dateTimeParser(date)}</span>;
const [formattedDate] = useState(dateTimeParser(date));

if (!formattedDate) {
return <span className="h-4 w-16 rounded-md bg-slate-300 dark:bg-slate-600" />;
}

return <span className={className}>{formattedDate}</span>;
};

export default DateTime;

0 comments on commit 73877da

Please sign in to comment.