refactor: simplify example app by moving renderBoard call into useGame

- Remove useMounted and manual renderBoard call from example App
- Call renderBoard from useGame useEffect on initialization
- Follow vim-maze pattern for cleaner example app
This commit is contained in:
2025-11-03 21:46:42 +00:00
parent c036dc372d
commit fb79aa0229
2 changed files with 7 additions and 18 deletions
+6 -1
View File
@@ -1,4 +1,4 @@
import { useState } from "react";
import { useState, useEffect } from "react";
import type { GameManager, GameOptions, KeyLogEntry } from "../types";
import { useBoard } from "../useBoard";
import { useCursor } from "../useCursor";
@@ -21,6 +21,11 @@ export function useGame(
boardManager.renderBoard(cursorManager.position());
};
// Initial render on mount
useEffect(() => {
renderBoardWrapped();
}, []);
const gameManager: GameManager = {
containerRef: boardManager.containerRef,
renderBoard: renderBoardWrapped,