diff --git a/src/minesweeper/Minesweeper.tsx b/src/minesweeper/Minesweeper.tsx index f57b52c..4a166cb 100644 --- a/src/minesweeper/Minesweeper.tsx +++ b/src/minesweeper/Minesweeper.tsx @@ -75,12 +75,12 @@ function Minesweeper() { // Save game state on change useEffect(() => { - autorun((reaction) => { + const disposer = autorun(() => { const gamestate = game.Export(); localStorage.setItem("gamestate", SerializeGameState(gamestate)); console.log("Saved gamestate"); - reaction.dispose(); }); + return () => disposer(); }, []) const boardTileStyle = { diff --git a/src/minesweeper/minesweeper-game.ts b/src/minesweeper/minesweeper-game.ts index af46ed2..8458799 100644 --- a/src/minesweeper/minesweeper-game.ts +++ b/src/minesweeper/minesweeper-game.ts @@ -83,7 +83,7 @@ export class MinesweeperGame { return { BoardRows: this.boardRows, BoardColumns: this.boardColumns, - BoardData: this._board, + BoardData: this._board.slice(), MineCount: this.mineCount, Seed: this._seed, isOver: this.isOver,