Skip to content

Commit

Permalink
Clean Up Of Performance Issues
Browse files Browse the repository at this point in the history
  • Loading branch information
kvebers committed Apr 14, 2024
1 parent 229b632 commit feab292
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions frontend/src/pages/Games/Tournament.js
Original file line number Diff line number Diff line change
Expand Up @@ -938,7 +938,7 @@ const Tournament = () => {
</div>
);
}

const interval = useRef(null);
useEffect(() => {
if (pageToRender === 3) {
const canvas = canvasRef.current;
Expand All @@ -957,7 +957,7 @@ const Tournament = () => {
// eslint-disable-next-line react-hooks/exhaustive-deps
scorePlayer2 = 0;
ctxRef.current = ctx;
const interval = setInterval(() => update(canvas, ctx), 1000 / 30);
interval.current = setInterval(() => update(canvas, ctx), 1000 / 30);
return () => clearInterval(interval);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
Expand Down Expand Up @@ -1031,6 +1031,7 @@ const Tournament = () => {
if (scorePlayer1 >= 2 || scorePlayer2 >= 2) {
ballSpeed = 0;
updateResults();
clearInterval(interval.current);
if (tournament.matches.length !== 0) setPageToRender(2);
else setPageToRender(4);
}
Expand Down

0 comments on commit feab292

Please sign in to comment.