-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b31afdc
commit 9a3550f
Showing
4 changed files
with
35 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,4 +13,5 @@ export default function DashBoard() { | |
</div> | ||
|
||
) | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,28 @@ | ||
export default function GameCell() { | ||
import { useContext } from "react" | ||
import { GameState } from "../ContextFile" | ||
import { FaO, FaX } from "react-icons/fa6" | ||
|
||
export default function GameCell( { index } ) { | ||
|
||
const [player, setPlayer, boardState, setBoardState, result, setResult] = useContext(GameState) | ||
|
||
const clickHandler = (e) => { | ||
const cellToAlter = e.target.classList[0] | ||
const updatedBoardState = [...boardState] | ||
updatedBoardState[cellToAlter] = player | ||
setBoardState(updatedBoardState) | ||
|
||
setPlayer(player === 1 ? 2 : 1) | ||
console.log(player) | ||
} | ||
|
||
return ( | ||
<div className="game-cell w-28 h-28 m-2 bg-slate-400"></div> | ||
<div className={`${index} game-cell w-28 h-28 m-2 bg-slate-400`} onClick={clickHandler}> | ||
{ | ||
boardState[index] === 1 ? <FaO style={{display: "block"}} /> : boardState[index] === 2 ? <FaX style={{display: "block"}} /> : null | ||
|
||
} | ||
|
||
</div> | ||
) | ||
} |
9a3550f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
react-mini-projects-cuqx – ./
react-mini-projects-cuqx.vercel.app
react-mini-projects-cuqx-steven-brooks-projects.vercel.app
react-mini-projects-cuqx-git-main-steven-brooks-projects.vercel.app
9a3550f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
react-mini-projects-uh67 – ./
react-mini-projects-uh67-steven-brooks-projects.vercel.app
react-mini-projects-uh67-git-main-steven-brooks-projects.vercel.app
react-mini-projects-uh67.vercel.app