-
Notifications
You must be signed in to change notification settings - Fork 0
Conversation
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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
zustundの方で値を管理するようにしてもらえると
(これだとscoreの値が変わるたびに全体が再レンダリングされてしまうので)
src/pages/result/index.tsx
Outdated
</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`} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ハックツの夏祭りように改修してるので、
#ハックツ夏祭り
のハッシュハグつけるようにしてもらえると
src/pages/shooter/index.tsx
Outdated
setScore((prevScore) => prevScore + 1); | ||
console.log(score); | ||
const newScore = score + 1; | ||
setScoreState(newScore); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
setScoreState(newScore); | |
setScoreState((prev) => prev + 1); |
こんな感じで値の更新をしないと正しくstateが更新されない場合があるので、変更お願いします
src/pages/shooter/index.tsx
Outdated
} | ||
}); | ||
}, [onMessage, uuid, score]); | ||
|
||
useEffect(() => { | ||
if (images.length === 0) { | ||
setScore(score); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
この処理の意味を教えてください
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
これは、images(コルクの残量)が0になったときにresultに遷移する処理です!
No description provided.