Skip to content

Commit c01daac

Browse files
committed
Fixing bug whereby the game was resetting in an infinite loop
1 parent fa7b86c commit c01daac

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/pages/Game/Game.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,20 @@ const Game = () => {
3838
await dispatch(GameService.getAllPlayers()).catch((e: Error) =>
3939
enqueueSnackbar(parseError(e), { variant: "error" }),
4040
)
41-
}, [iamSpectator])
41+
}, [id, iamSpectator])
4242

4343
useEffect(() => {
4444
fetchData()
45+
}, [id, iamSpectator])
4546

47+
useEffect(() => {
4648
return () => {
47-
console.log("Resetting game")
48-
dispatch(resetGame())
49+
console.log("Clearing game")
4950
dispatch(clearMyCards())
5051
dispatch(clearAutoPlay())
52+
dispatch(resetGame())
5153
}
52-
}, [id, iamSpectator])
54+
}, [])
5355

5456
return (
5557
<PullToRefresh

0 commit comments

Comments
 (0)