Skip to content

Commit

Permalink
Clear timeout in useEffect (#174)
Browse files Browse the repository at this point in the history
Fixes #173
  • Loading branch information
chunweii authored Oct 26, 2023
1 parent c1ff1fa commit ae0c485
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion frontend/src/pages/interviews/find-match.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,19 @@ export default function FindMatch() {
};

useEffect(() => {
let timeout: ReturnType<typeof setTimeout> | null = null;
if (match) {
router.push("/interviews/match-found");
} else {
setTimeout(() => {
timeout = setTimeout(() => {
cancelLooking();
router.push("/interviews/match-not-found");
}, 30000);
}
return () => {
if (timeout)
clearTimeout(timeout);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [match, router]);

Expand Down

0 comments on commit ae0c485

Please sign in to comment.