From e7ebf3e715543a3f406dbdfedea57025421e23f1 Mon Sep 17 00:00:00 2001 From: Sea10wood Date: Sat, 17 Aug 2024 16:34:34 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20Local=E3=81=A7=E3=81=AE=E5=A4=89?= =?UTF-8?q?=E6=95=B0=E5=90=8D=E3=81=AE=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/shooter/index.tsx | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/pages/shooter/index.tsx b/src/pages/shooter/index.tsx index 6510029..bba5681 100644 --- a/src/pages/shooter/index.tsx +++ b/src/pages/shooter/index.tsx @@ -17,7 +17,7 @@ type ShooterProps = { const Shooter = ({ setScore }: ShooterProps) => { const [isOpen, setIsOpen] = useState(true); - const [score, setLocalScore] = useState(0); + const [score, setScoreState] = useState(0); const { orientationDiff } = useOrientation(); const { sendData } = useSocketSender(); const { onMessage } = useSocketReceiver(); @@ -49,17 +49,17 @@ const Shooter = ({ setScore }: ShooterProps) => { onMessage((data) => { if (data.message_type === MessageType.Hit && data.id === uuid) { const newScore = score + 1; - setLocalScore(newScore); - setScore(newScore); + setScoreState(newScore); } }); - }, [onMessage, uuid, score, setScore]); + }, [onMessage, uuid, score]); useEffect(() => { if (images.length === 0) { + setScore(score); navigate("/result", { state: { score } }); } - }, [images, navigate, score]); + }, [images, navigate, score, setScore]); const handleClick = () => { const audio = new Audio("/sound/cork_sound.mp3"); @@ -103,6 +103,7 @@ type ModalContentProps = { }; const ModalContent: React.FC = ({ setIsOpen }) => { + const { reset } = useOrientation(); return (
= ({ setIsOpen }) => { variant="outlined" color="red" size="md" - onClick={() => setIsOpen(false)} + onClick={() => { + reset(); + setIsOpen(false); + }} > 置いたよ!