diff --git a/src/App.js b/src/App.js index 10bd381..5cb99b1 100644 --- a/src/App.js +++ b/src/App.js @@ -1,17 +1,12 @@ import './App.css'; import { useState } from 'react'; -function Square() { - const [value, setValue] = useState(null); - - function handleClick() { - setValue('X') - } +function Square({value, onSquareClick}) { return ( @@ -19,22 +14,31 @@ function Square() { } function App() { + + const [squares, setSquares] = useState(Array(9).fill(null)); + + function handleClick(i) { + const nextSquares = squares.slice(); + nextSquares[i] = "X"; + setSquares(nextSquares); + } + return ( <>