Skip to content

Commit

Permalink
Fix improper autorun disposal. Fix game export.
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeldoylecs committed Dec 3, 2024
1 parent 0ce3a45 commit 2b6cdb5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/minesweeper/Minesweeper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
2 changes: 1 addition & 1 deletion src/minesweeper/minesweeper-game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 2b6cdb5

Please sign in to comment.