Skip to content

Commit

Permalink
feat(react): avoid click if already checkd
Browse files Browse the repository at this point in the history
  • Loading branch information
budougumi0617 committed Oct 6, 2024
1 parent e0bb1f7 commit fcf6a92
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions react/tic-tac-toe/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ export default function Board() {
Array<string | null>(9).fill(null),
);
const handleClick = (i: number) => {
if (squares[i]) {
// 入力済みのマス目をクリックした場合は何もしない
return;
}

const nextSquares = squares.slice();
if (xIsNext) {
nextSquares[i] = "X";
Expand Down

0 comments on commit fcf6a92

Please sign in to comment.