Skip to content

Commit

Permalink
Fixing bug whereby the game was resetting in an infinite loop
Browse files Browse the repository at this point in the history
  • Loading branch information
daithihearn committed Feb 2, 2023
1 parent fa7b86c commit c01daac
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/pages/Game/Game.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,20 @@ const Game = () => {
await dispatch(GameService.getAllPlayers()).catch((e: Error) =>
enqueueSnackbar(parseError(e), { variant: "error" }),
)
}, [iamSpectator])
}, [id, iamSpectator])

useEffect(() => {
fetchData()
}, [id, iamSpectator])

useEffect(() => {
return () => {
console.log("Resetting game")
dispatch(resetGame())
console.log("Clearing game")
dispatch(clearMyCards())
dispatch(clearAutoPlay())
dispatch(resetGame())
}
}, [id, iamSpectator])
}, [])

return (
<PullToRefresh
Expand Down

0 comments on commit c01daac

Please sign in to comment.