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

View File

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