import React, { useState } from 'react'; import Cell from './Cell'; interface Props { width?: number; height?: number; } const Board = (props: Props) => { const width = props.width ?? 5; const height = props.height ?? 5; const initialGrid: boolean[][] = Array(height).fill(Array(width).fill(false)); const [grid, setGrid] = useState(initialGrid); const toggle = (x: number, y: number) => { const newGrid = [...grid]; const newRow = [...newGrid[y]]; newRow[x] = !newGrid[y][x]; newGrid[y] = newRow; setGrid(newGrid); }; return (
{grid.map((row, y) => (
{row.map((cell, x) => ( ))}
))}
); }; export default Board;