Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions viewer/src/pages/EventItemSummaryPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ export function EventItemSummaryPage() {
const [loading, setLoading] = useState(true);
const [error, setError] = useState<string | null>(null);

const event = events.find((e) => e.eventId === eventId);

useEffect(() => {
if (!eventId) return;
const event = events.find((e) => e.eventId === eventId);
if (!event) return;
Comment on lines 19 to 22
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

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

events.find(...) for the selected event is duplicated (once inside the effect and again during render). To avoid the two lookups drifting and to keep the hook deps simple, consider deriving event once (e.g., via useMemo keyed by [events, eventId]) and reusing it in both the effect and the render guard.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

ご指摘ありがとうございます。二重呼び出しは冗長ですが、このPRのスコープは最小限に保ちます。EventItemSummaryPage は別PR(#11)で useFetchData フックへ完全にリファクタリングされるため、ここで useMemo を追加するのは過渡的な変更になります。


const controller = new AbortController();
Expand Down Expand Up @@ -57,9 +57,10 @@ export function EventItemSummaryPage() {
if (!controller.signal.aborted) setLoading(false);
});
return () => controller.abort();
}, [event, exclusions]);
}, [eventId, events, exclusions]);

if (!eventId) return null;
if (!eventId) return <Navigate to="/" replace />;
const event = events.find((e) => e.eventId === eventId);
if (!event) return <Navigate to="/" replace />;
if (loading || error) return <LoadingError loading={loading} error={error} />;

Expand Down
2 changes: 1 addition & 1 deletion viewer/src/pages/ReportersPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export function ReportersPage() {
const { eventId } = useParams<{ eventId: string }>();
const { events, exclusions } = useOutletContext<LayoutContext>();

if (!eventId) return null;
if (!eventId) return <Navigate to="/" replace />;

const event = events.find((e) => e.eventId === eventId);
if (!event) return <Navigate to="/" replace />;
Expand Down