diff --git a/apps/client/src/scenes/result/ResultScene.tsx b/apps/client/src/scenes/result/ResultScene.tsx
index 70efd8c..39116df 100644
--- a/apps/client/src/scenes/result/ResultScene.tsx
+++ b/apps/client/src/scenes/result/ResultScene.tsx
@@ -38,17 +38,12 @@
setActiveTab,
} = useResultView(result);
- if (!result) {
- return (
-
結果を読み込み中...
- );
- }
-
+ // hooksはearly returnより前に呼ぶ必要があるため,resultがnullの場合はフォールバック値を使用
const winnerTeamId = useMemo(
() =>
- result.rankings.find((row) => row.rank === 1)?.teamId ??
- result.rankings[0]?.teamId,
- [result.rankings],
+ result?.rankings.find((row) => row.rank === 1)?.teamId ??
+ result?.rankings[0]?.teamId,
+ [result?.rankings],
);
const winnerColor = useMemo(
() => config.GAME_CONFIG.TEAM_COLORS[winnerTeamId ?? -1] ?? "#888888",
@@ -60,19 +55,25 @@
const finalGridColors = useMemo(
() =>
Array.from({ length: totalCells }, (_, index) => {
- const teamId = result.finalGridColors?.[index];
+ const teamId = result?.finalGridColors?.[index];
return typeof teamId === "number" ? teamId : -1;
}),
- [result.finalGridColors, totalCells],
+ [result?.finalGridColors, totalCells],
);
+ if (!result) {
+ return (
+ 結果を読み込み中...
+ );
+ }
+
return (
{
+ onPointerDown={() => {
if (isRankingVisible) {
return;
}
diff --git a/apps/client/src/scenes/title/TitleScene.tsx b/apps/client/src/scenes/title/TitleScene.tsx
index d261437..031e306 100644
--- a/apps/client/src/scenes/title/TitleScene.tsx
+++ b/apps/client/src/scenes/title/TitleScene.tsx
@@ -70,7 +70,7 @@
cursor: showForm ? "default" : "pointer",
}}
// 🌟 追加:背景のどこかをタップしたらフォームを表示する
- onClick={() => {
+ onPointerDown={() => {
if (!showForm) setShowForm(true);
}}
>