-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp1.js
40 lines (40 loc) · 1.2 KB
/
App1.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import { useState } from "react";
import Box from "./Box";
import BoxGame from "./BoxGame";
import "./App.css";
export default function App1() {
const [show, setShow] = useState(true);
const handle_click = () => {
alert("I met you in the afternoon after work")
}
const [board, setBoard] = useState(["", "", "", "", "", "", "", "", ""]);
const handle_play = (index) => {
let newBoard = [...board];
newBoard[index] = show ? "X" : "O";
setBoard(newBoard);
setShow(!show);
if (!show) {
setShow(false)
}
if(setShow(false)){
setShow(true)
}
}
// if (!show) {
// handle_play();
// setBoard(true);
// }
return (
<div>
{/* {show ? <Box old={8} name={"Le Cho"} handle_click={handle_click} /> : ""} */}
{/* <button onClick={() => setShow(!show)}>Toggle mount</button> */}
<div className="game">
{board.map((value, key) => {
return (
<BoxGame value={board[key]} handle_play={handle_play} index={key} />
)
})}
</div>
</div>
)
}