I need to run side effects based on changes in live queries to update some in-game components.
const {
fetch: getGameData,
data: [liveGameData],
error: gameError,
isLoading: isGameLoading,
} = useMoralisQuery(
"Game",
(query) => query.equalTo("challengeId", liveChallengeId).limit(1),
[liveChallengeId],
{
autoFetch: true,
live: true,
}
);
useEffect(() => {
console.log("Updating Chess Object");
const _chess = new Chess();
chess.load_pgn(liveGameData?.attributes?.pgn || "");
setLiveGameObj(_chess);
}, [liveGameData]);
Iβve tried many methods to get this effect to work if there are any changes in the pgn
field of the row in db. The network tab shows that there have been updates to the socket but it doesnβt reflect in any effect kicking in.