Press n or j to go to the next uncovered block, b, p or k for the previous block.
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 | // import React, { useEffect, useState } from 'react'; // import { useWebSocket } from '../../contexts/WebSocketContext'; // export default function GameTimer() // { // const { lastMessage } = useWebSocket(); // const [timeLeft, setTimeLeft] = useState<number | null>(null); // useEffect(() => { // console.log('[GameTimer] lastMessage:', lastMessage); // if(lastMessage?.type === 'TIMER_UPDATE') // { // setTimeLeft(lastMessage.payload.secondsLeft); // } // else if(lastMessage?.type === 'GAME_OVER') // { // setTimeLeft(0); // } // }, [lastMessage]); // return ( // <div> // {timeLeft === null && <h2>Waiting for timer...</h2>} // {timeLeft !== null && timeLeft > 0 && <h2>Time Left: {timeLeft}s</h2>} // {timeLeft === 0 && <h2> TimeOver</h2>} // </div> // ); // } |