Fix HoF display for transfers/shinies and hook ordering
Move alive and hofTeam into useMemo hooks above early returns to fix React hook ordering violation. Include transfer and shiny encounters in alive so they appear in the team section and can be selected for the Hall of Fame. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -620,12 +620,19 @@ export function RunEncounters() {
|
||||
}
|
||||
}, [organizedRoutes, encounterByRoute]) // eslint-disable-line react-hooks/exhaustive-deps
|
||||
|
||||
const alive = useMemo(
|
||||
() => [...normalEncounters, ...transferEncounters, ...shinyEncounters].filter(
|
||||
(e) => e.status === 'caught' && e.faintLevel === null,
|
||||
),
|
||||
[normalEncounters, transferEncounters, shinyEncounters],
|
||||
)
|
||||
|
||||
// Resolve HoF team encounters from IDs
|
||||
const hofTeam = useMemo(() => {
|
||||
if (!run?.hofEncounterIds || run.hofEncounterIds.length === 0) return null
|
||||
const idSet = new Set(run.hofEncounterIds)
|
||||
return normalEncounters.filter((e) => idSet.has(e.id))
|
||||
}, [run?.hofEncounterIds, normalEncounters])
|
||||
return alive.filter((e) => idSet.has(e.id))
|
||||
}, [run?.hofEncounterIds, alive])
|
||||
|
||||
if (isLoading || loadingRoutes) {
|
||||
return (
|
||||
@@ -679,9 +686,6 @@ export function RunEncounters() {
|
||||
}
|
||||
|
||||
const isActive = run.status === 'active'
|
||||
const alive = normalEncounters.filter(
|
||||
(e) => e.status === 'caught' && e.faintLevel === null,
|
||||
)
|
||||
const dead = normalEncounters.filter(
|
||||
(e) => e.status === 'caught' && e.faintLevel !== null,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user