fix : infinite rerenders

This commit is contained in:
GuillaumeSD
2024-02-25 03:02:59 +01:00
parent 7412f708d0
commit 2af25cf4ec
11 changed files with 50 additions and 47 deletions

View File

@@ -5,7 +5,7 @@ import { boardAtom, gameAtom } from "../states";
import { useChessActions } from "@/hooks/useChess";
export default function NextMoveButton() {
const boardActions = useChessActions(boardAtom);
const { makeMove: makeBoardMove } = useChessActions(boardAtom);
const game = useAtomValue(gameAtom);
const board = useAtomValue(boardAtom);
@@ -23,7 +23,7 @@ export default function NextMoveButton() {
const nextMove = game.history({ verbose: true })[nextMoveIndex];
if (nextMove) {
boardActions.move({
makeBoardMove({
from: nextMove.from,
to: nextMove.to,
promotion: nextMove.promotion,