import './App.css'; import { useState } from 'react'; function Square({value, onSquareClick}) { return ( ); } function App() { const [xIsNext, setXIsNext] = useState(true); const [squares, setSquares] = useState(Array(9).fill(null)); function handleClick(i) { const nextSquares = squares.slice(); if (xIsNext) { nextSquares[i] = "X"; } else { nextSquares[i] = "O"; } setSquares(nextSquares); setXIsNext(!xIsNext); } return ( <>
handleClick(0)}/> handleClick(1)}/> handleClick(2)}/>
handleClick(3)}/> handleClick(4)}/> handleClick(5)}/>
handleClick(6)}/> handleClick(7)}/> handleClick(8)}/>
); } export default App;