import React from 'react'
import './App.css'
const CELL_COUNT = 25
function App() {
const [cells] = React.useState(Array.from({ length: CELL_COUNT }, (_, i) => i))
const [randomCell, setRandomCell] = React.useState(null)
const playClick = () => setRandomCell(parseInt(Math.random() * CELL_COUNT))
const greenClick = () => setRandomCell(null)
return (
<div className="game">
<div>
<button onClick={playClick}>Play</button>
</div>
<div>
{cells.map((cell, idx) => <button
key={cell}
className={idx === randomCell ? 'cell random' : 'cell'}
onClick={randomCell && greenClick}
>{cell}</button>)}
</div>
</div>
)
}
export default App