matchId check in Board instead of TicTacToe.tsx

This commit is contained in:
2025-11-29 02:52:34 +05:30
parent ebc6906bf6
commit 601048f0e4
2 changed files with 142 additions and 136 deletions

View File

@@ -1,5 +1,6 @@
import React from "react"; import React from "react";
import { motion, AnimatePresence } from "framer-motion"; import { motion, AnimatePresence } from "framer-motion";
import { useNakama } from "./providers/NakamaProvider";
interface BoardProps { interface BoardProps {
board: string[][]; board: string[][];
@@ -20,6 +21,9 @@ export default function Board({
}: BoardProps) { }: BoardProps) {
const myIndex = players.indexOf(myUserId ?? ""); const myIndex = players.indexOf(myUserId ?? "");
const gameReady = players.length === 2; const gameReady = players.length === 2;
const {
matchId
} = useNakama();
const mySymbol = const mySymbol =
myIndex === 0 ? "X" : myIndex === 1 ? "O" : null; myIndex === 0 ? "X" : myIndex === 1 ? "O" : null;
@@ -44,6 +48,8 @@ export default function Board({
} }
return ( return (
<>
{matchId && (
<motion.div <motion.div
initial={{ opacity: 0, y: 10 }} initial={{ opacity: 0, y: 10 }}
animate={{ opacity: 1, y: 0 }} animate={{ opacity: 1, y: 0 }}
@@ -173,5 +179,7 @@ export default function Board({
</motion.div> </motion.div>
)} )}
</motion.div> </motion.div>
); )}
</>
)
} }

View File

@@ -80,7 +80,6 @@ export default function TicTacToe() {
onMatchDataCallback={onMatchDataCallback} onMatchDataCallback={onMatchDataCallback}
/> />
{matchId && (
<Board <Board
board={board} board={board}
turn={turn} turn={turn}
@@ -89,7 +88,6 @@ export default function TicTacToe() {
myUserId={session?.user_id ?? null} myUserId={session?.user_id ?? null}
onCellClick={handleCellClick} onCellClick={handleCellClick}
/> />
)}
</div> </div>
); );
} }