fix: odd grid issues

pull/1500/head
prathoseraaj 11 months ago
parent 6a240ae689
commit 1ec5b53f9f

@ -24,13 +24,13 @@ const MemoryGame = () => {
const [won, setWon] = useState(false); const [won, setWon] = useState(false);
const handleGridSize = (e) => { const handleGridSize = (e) => {
const size = parseInt(e.target.value); const size = parseInt(e.target.value);
if (2 <= size && size <= 10 && (size * size) % 2 === 0) { if (2 <= size && size <= 10 && (size * size) % 2 === 0) {
setGridSize(size); setGridSize(size);
setError(""); setError("");
} else { } else {
setError("Please enter a grid size where gridSize x gridSize is even (e.g. 2, 4, 6, 8, 10)"); setError("Please enter a grid size where gridSize x gridSize is even (e.g. 2, 4, 6, 8, 10)");
} }
}; };
const initializeGame = useCallback(() => { const initializeGame = useCallback(() => {
@ -115,6 +115,9 @@ const MemoryGame = () => {
value={gridSize} value={gridSize}
onChange={handleGridSize} onChange={handleGridSize}
/> />
{error && (
<div className="text-sm text-red-500 mt-2">{error}</div>
)}
</div> </div>
{/* Cards */} {/* Cards */}
<div <div

Loading…
Cancel
Save