mirror of
https://github.com/DI0IK/homepage-plus.git
synced 2025-07-10 15:28:47 +00:00
Fix datetime react render error
This commit is contained in:
parent
9de82559ca
commit
812eb3d70f
1 changed files with 6 additions and 7 deletions
|
@ -15,22 +15,21 @@ const textSizes = {
|
|||
export default function DateTime({ options }) {
|
||||
const { text_size: textSize, format } = options;
|
||||
const { i18n } = useTranslation();
|
||||
const [date, setDate] = useState(new Date());
|
||||
|
||||
const dateFormat = new Intl.DateTimeFormat(i18n.language, { ...format });
|
||||
const [date, setDate] = useState("");
|
||||
|
||||
useEffect(() => {
|
||||
const interval = setInterval(() => {
|
||||
setDate(new Date());
|
||||
setDate(dateFormat.format(new Date()));
|
||||
}, 1000);
|
||||
return () => clearInterval(interval);
|
||||
}, [setDate]);
|
||||
|
||||
const dateFormat = new Intl.DateTimeFormat(i18n.language, { ...format });
|
||||
}, [date, setDate]);
|
||||
|
||||
return (
|
||||
<div className="flex flex-col justify-center first:ml-0 ml-4">
|
||||
<div className="flex flex-row items-center grow justify-end">
|
||||
<span className={`text-theme-800 dark:text-theme-200 ${textSizes[textSize || "lg"]}`}>
|
||||
{dateFormat.format(date)}
|
||||
{date}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue