The useEffect dependencies array has response in it while it uses setResponse in its execution. Therefore it should trigger an infinite loop that loads the game indefinitely.
A good React practice is to never set a state in a useEffect if it is in its dependencies array.
That is not the case, no infinite loop is created.
It's an intended feature to request the actual game state and deal with appropriately if the server responds the user is already in a game
Hi,
Following up on your message here : https://github.com/Clariity/react-chessboard/issues/119#issuecomment-2293317366
I think the issue you are seeing comes at least from this : https://github.com/Gen1Code/Chess-Lights-Out/blob/919d3aef896f04dac4cd9da5ffbc135033065e28/frontend/src/context/GameContext.jsx#L122
The useEffect dependencies array has
response
in it while it usessetResponse
in its execution. Therefore it should trigger an infinite loop that loads the game indefinitely.A good React practice is to never set a state in a useEffect if it is in its dependencies array.