Fix hooks order violation in RunEncounters
Move hofTeam useMemo before early returns to comply with Rules of Hooks. It was placed after the loading/error guards, causing a "rendered more hooks than during the previous render" crash. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -610,6 +610,13 @@ export function RunEncounters() {
|
|||||||
}
|
}
|
||||||
}, [organizedRoutes, encounterByRoute]) // eslint-disable-line react-hooks/exhaustive-deps
|
}, [organizedRoutes, encounterByRoute]) // eslint-disable-line react-hooks/exhaustive-deps
|
||||||
|
|
||||||
|
// 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])
|
||||||
|
|
||||||
if (isLoading || loadingRoutes) {
|
if (isLoading || loadingRoutes) {
|
||||||
return (
|
return (
|
||||||
<div className="flex items-center justify-center py-16">
|
<div className="flex items-center justify-center py-16">
|
||||||
@@ -669,13 +676,6 @@ export function RunEncounters() {
|
|||||||
(e) => e.status === 'caught' && e.faintLevel !== null,
|
(e) => e.status === 'caught' && e.faintLevel !== null,
|
||||||
)
|
)
|
||||||
|
|
||||||
// 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])
|
|
||||||
|
|
||||||
const toggleGroup = (groupId: number) => {
|
const toggleGroup = (groupId: number) => {
|
||||||
updateExpandedGroups((prev) => {
|
updateExpandedGroups((prev) => {
|
||||||
const next = new Set(prev)
|
const next = new Set(prev)
|
||||||
|
|||||||
Reference in New Issue
Block a user