mirror of
https://github.com/DI0IK/homepage-plus.git
synced 2025-07-10 23:38:46 +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 }) {
|
export default function DateTime({ options }) {
|
||||||
const { text_size: textSize, format } = options;
|
const { text_size: textSize, format } = options;
|
||||||
const { i18n } = useTranslation();
|
const { i18n } = useTranslation();
|
||||||
const [date, setDate] = useState(new Date());
|
const dateFormat = new Intl.DateTimeFormat(i18n.language, { ...format });
|
||||||
|
const [date, setDate] = useState("");
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const interval = setInterval(() => {
|
const interval = setInterval(() => {
|
||||||
setDate(new Date());
|
setDate(dateFormat.format(new Date()));
|
||||||
}, 1000);
|
}, 1000);
|
||||||
return () => clearInterval(interval);
|
return () => clearInterval(interval);
|
||||||
}, [setDate]);
|
}, [date, setDate]);
|
||||||
|
|
||||||
const dateFormat = new Intl.DateTimeFormat(i18n.language, { ...format });
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col justify-center first:ml-0 ml-4">
|
<div className="flex flex-col justify-center first:ml-0 ml-4">
|
||||||
<div className="flex flex-row items-center grow justify-end">
|
<div className="flex flex-row items-center grow justify-end">
|
||||||
<span className={`text-theme-800 dark:text-theme-200 ${textSizes[textSize || "lg"]}`}>
|
<span className={`text-theme-800 dark:text-theme-200 ${textSizes[textSize || "lg"]}`}>
|
||||||
{dateFormat.format(date)}
|
{date}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue