onEndGame
Called during the game”s end with the result.
Returns the games result and winning color.
Typing
type GameResult = {
resultType: "mat" | "pat" | "draw";
winColor?: "white" | "black";
};
type onChange = (gameResult: GameResult) => void;
Code
export const App = () => {
const handleEndGame = (gameResult) => {
saveGameResult(gameResult);
}
return (
<ChessBoard
FEN="rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1"
onChange={() => {}}
onEndGame={handleEndGame}
/>
);
}