Procházet zdrojové kódy

fix another react deps warning

Michael Shamoon před 2 roky
rodič
revize
98c8f2078d
1 změnil soubory, kde provedl 2 přidání a 2 odebrání
  1. 2 2
      src/components/widgets/datetime/datetime.jsx

+ 2 - 2
src/components/widgets/datetime/datetime.jsx

@@ -15,15 +15,15 @@ const textSizes = {
 export default function DateTime({ options }) {
   const { text_size: textSize, format } = options;
   const { i18n } = useTranslation();
-  const dateFormat = new Intl.DateTimeFormat(i18n.language, { ...format });
   const [date, setDate] = useState("");
   
   useEffect(() => {
+    const dateFormat = new Intl.DateTimeFormat(i18n.language, { ...format });
     const interval = setInterval(() => {
       setDate(dateFormat.format(new Date()));
     }, 1000);
     return () => clearInterval(interval);
-  }, [date, setDate, dateFormat]);
+  }, [date, setDate, i18n.language, format]);
 
   return (
     <div className="flex flex-col justify-center first:ml-0 ml-4">