From 65fcd94f07374e1293e0237ce35dc417c984b0a5 Mon Sep 17 00:00:00 2001 From: Mohamed Khelif Date: Wed, 13 Dec 2023 14:36:16 -0500 Subject: [PATCH] Add dependency array --- src/pages/task/metadata/ETATimer/index.tsx | 10 ++++++---- src/pages/task/metadata/RuntimeTimer/index.tsx | 3 ++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/pages/task/metadata/ETATimer/index.tsx b/src/pages/task/metadata/ETATimer/index.tsx index 663f333bd9..3999850764 100644 --- a/src/pages/task/metadata/ETATimer/index.tsx +++ b/src/pages/task/metadata/ETATimer/index.tsx @@ -27,12 +27,14 @@ const ETATimer: React.FC = ({ expectedDuration, startTime }) => { Date.now() ); setEta(newEta > 0 ? newEta : 0); + if (newEta <= 0) { + clearInterval(timer); + } }, 1000); - if (eta === 0) { - clearInterval(timer); - } + return () => clearInterval(timer); - }); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, []); return ( diff --git a/src/pages/task/metadata/RuntimeTimer/index.tsx b/src/pages/task/metadata/RuntimeTimer/index.tsx index df398d8bf9..370d4266e5 100644 --- a/src/pages/task/metadata/RuntimeTimer/index.tsx +++ b/src/pages/task/metadata/RuntimeTimer/index.tsx @@ -25,7 +25,8 @@ const RuntimeTimer: React.FC = ({ startTime }) => { }, 1000); return () => clearInterval(timer); - }); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, []); return (