From f1c2175153aee84210434ff24689fabb1d5689fe Mon Sep 17 00:00:00 2001 From: "Kalle (Sendou)" <38327916+Sendouc@users.noreply.github.com> Date: Thu, 20 Jan 2022 21:52:03 +0200 Subject: [PATCH] Actually fix the hooks out of sync warning --- app/components/tournament/CheckinActions.tsx | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/app/components/tournament/CheckinActions.tsx b/app/components/tournament/CheckinActions.tsx index 6d9211776..7ba6ff813 100644 --- a/app/components/tournament/CheckinActions.tsx +++ b/app/components/tournament/CheckinActions.tsx @@ -31,6 +31,14 @@ export function CheckinActions() { const [minutesTillCheckInCloses, setMinutesTillCheckInCloses] = React.useState(timeInMinutesBeforeCheckInCloses()); + React.useEffect(() => { + const timeout = setInterval(() => { + setMinutesTillCheckInCloses(timeInMinutesBeforeCheckInCloses()); + }, 1000 * 15); + + return () => clearTimeout(timeout); + }, []); + const ownTeam = tournament.teams.find((team) => team.members.some( ({ member, captain }) => captain && member.id === user?.id @@ -42,14 +50,6 @@ export function CheckinActions() { return null; } - React.useEffect(() => { - const timeout = setInterval(() => { - setMinutesTillCheckInCloses(timeInMinutesBeforeCheckInCloses()); - }, 1000 * 15); - - return () => clearTimeout(timeout); - }, []); - if (ownTeam.checkedInTime) { return (