Skip to content
This repository has been archived by the owner on Nov 26, 2024. It is now read-only.

Add: shooter_scoreを元にresultへの遷移 #46

Merged
merged 8 commits into from
Aug 18, 2024
Merged

Add: shooter_scoreを元にresultへの遷移 #46

merged 8 commits into from
Aug 18, 2024

Conversation

Sea10wood
Copy link
Collaborator

No description provided.

src/App.tsx Outdated
import { Route, Routes } from "react-router-dom";
import Home from "./pages/home";
import Result from "./pages/result";
import Shooter from "./pages/shooter";
import Yatai from "./pages/yatai";

const AppRoutes = () => {
const [score, setScore] = useState(0);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

zustundの方で値を管理するようにしてもらえると
(これだとscoreの値が変わるたびに全体が再レンダリングされてしまうので)

</div>
<div className={styles["share-btn"]}>
<a
href="https://twitter.com/intent/tweet?text=Webの射的で遊んだよ.%20%23virtualnatsumatsuri%20%23炎上開発%20%23鹿児島ハッカソン"
href={`https://twitter.com/intent/tweet?text=Webの射的で遊んだよ。${score}本倒した!%20%23virtualnatsumatsuri`}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ハックツの夏祭りように改修してるので、
#ハックツ夏祭り
のハッシュハグつけるようにしてもらえると

setScore((prevScore) => prevScore + 1);
console.log(score);
const newScore = score + 1;
setScoreState(newScore);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
setScoreState(newScore);
setScoreState((prev) => prev + 1);

こんな感じで値の更新をしないと正しくstateが更新されない場合があるので、変更お願いします

}
});
}, [onMessage, uuid, score]);

useEffect(() => {
if (images.length === 0) {
setScore(score);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

この処理の意味を教えてください

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

これは、images(コルクの残量)が0になったときにresultに遷移する処理です!

@Sea10wood Sea10wood requested a review from K-Kizuku August 18, 2024 11:30
src/pages/shooter/index.tsx Outdated Show resolved Hide resolved
src/store/useScoreStore.ts Show resolved Hide resolved
src/pages/result/index.tsx Outdated Show resolved Hide resolved
@Sea10wood Sea10wood requested a review from K-Kizuku August 18, 2024 16:27
@K-Kizuku K-Kizuku merged commit f393272 into main Aug 18, 2024
3 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants