Skip to content

Commit 412b605

Browse files
ut42techclaude
andcommitted
fix(checkin): remove redundant selectedIds prune effect (render loop)
The prune useEffect depended on presentIdSet, which is recreated every render while state != ok (sessions = data?.sessions ?? [] makes a fresh [] each render), so the effect ran every render and setSelectedIds (ids.filter always returns a new array) re-rendered forever — "Maximum update depth exceeded" on the loading screen. The effect was also redundant: selectedPresentIds already filters selectedIds by presentIdSet at use-time, and every consumer (count, checkbox state, checkout) reads the present-filtered value, so stale stored selections are inert. Deleting the effect fixes the loop with no behavioral change. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent cc4f9c6 commit 412b605

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

apps/checkin/src/app/history/page.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -172,12 +172,11 @@ export default function HistoryPage() {
172172
);
173173
const presentIdSet = useMemo(() => new Set(presentIds), [presentIds]);
174174

175-
// 取得結果が変わったら、もう滞在中でない参加者を選択から外す
176-
// (旧 loadSessions の selectedIds 絞り込みを再取得後も維持)。
177-
useEffect(() => {
178-
setSelectedIds((ids) => ids.filter((id) => presentIdSet.has(id)));
179-
}, [presentIdSet]);
180-
175+
// 選択は保存値(selectedIds)を prune せず、使用時に present で絞り込む。
176+
// 再取得で滞在中でなくなった選択は selectedPresentIds 以降(カウント・チェック状態・
177+
// チェックアウト対象)すべてで除外されるため、保存値を間引く effect は不要。
178+
// (presentIdSet を deps にした setSelectedIds は、データ到着前の loading 中に
179+
// presentIdSet が毎レンダー再生成されるため無限ループになる)
181180
const selectedPresentIds = useMemo(
182181
() => selectedIds.filter((id) => presentIdSet.has(id)),
183182
[presentIdSet, selectedIds],

0 commit comments

Comments
 (0)