Browse Source

空调定时器

anxiaoxia 2 years ago
parent
commit
a4f6cdc7c7
1 changed files with 7 additions and 6 deletions
  1. 7 6
      src/pages/Equipment/components/deviceModal/airEq/index.jsx

+ 7 - 6
src/pages/Equipment/components/deviceModal/airEq/index.jsx

@@ -21,7 +21,7 @@ export default ({ spaceId, projectId }) => {
   const hasAir = true;
   const [isOpen, setIsOpen] = useState(true);
   const [imgSrc, setImgSrc] = useState(null);
-  const timer = useRef(null);
+  let timer = useRef(null);
   const [spaceStatus, setStatusText] = useState('null');
   const airExpend = [
     {
@@ -96,12 +96,13 @@ export default ({ spaceId, projectId }) => {
   };
 
   useEffect(() => {
-    // timer = setInterval(() => {
     getAirInfo(); // 获取空调状态
-    // }, 1000);
-    // return () => {
-    //   clearInterval(timer);
-    // };
+    timer = setInterval(() => {
+      getAirInfo(); // 获取空调状态
+    }, 1000);
+    return () => {
+      clearInterval(timer);
+    };
   }, []);
 
   const AirExpend = () => {