Skip to content

Commit

Permalink
Decrease dependency to the only one relevant
Browse files Browse the repository at this point in the history
  • Loading branch information
SSoelvsten committed Jul 28, 2024
1 parent de57e82 commit 2b0a8a7
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions game/src/game-screen/scoreboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ const ScoreBoard = ({ endTime, gameEnd, language, qualified, round, score, onTim
}`;
};

// TODO: stop timer update when 'won'.
useEffect(() => {
if (!isTimed || gameEnd) return;

Expand All @@ -46,14 +45,18 @@ const ScoreBoard = ({ endTime, gameEnd, language, qualified, round, score, onTim
setCurrTime(tick);
}, 50);
return () => clearInterval(timerId);
}, [isTimed, gameEnd]);

// eslint-disable-next-line react-hooks/exhaustive-deps
}, [gameEnd]);

useEffect(() => {
if (!isTimed || gameEnd) return;

const timeLeft = endTime - currTime;
if (timeLeft < 0) onTimeout();
}, [isTimed, gameEnd, currTime, endTime, onTimeout]);

// eslint-disable-next-line react-hooks/exhaustive-deps
}, [currTime]);

const timeLeft = endTime - currTime;
const timeAlarm: boolean = 0 < timeLeft && timeLeft < 10 * 1000;
Expand Down

0 comments on commit 2b0a8a7

Please sign in to comment.