fix: useMemo vor Early Returns verschieben (Rules of Hooks)
Some checks failed
CI / go-lint (push) Has been skipped
CI / python-lint (push) Has been skipped
CI / nodejs-lint (push) Has been skipped
CI / test-go-school (push) Successful in 30s
CI / test-go-edu-search (push) Successful in 28s
CI / test-python-klausur (push) Failing after 2m10s
CI / test-python-agent-core (push) Successful in 22s
CI / test-nodejs-website (push) Successful in 25s

boxZonesPct useMemo war nach bedingten Returns platziert, was gegen
Reacts Rules of Hooks verstoesst und einen Client-Side Crash ausloest.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Benjamin Admin
2026-03-10 22:57:25 +01:00
parent f468c30112
commit 9dbb5fa708

View File

@@ -427,6 +427,20 @@ export function StepReconstruction({ sessionId, onNext }: StepReconstructionProp
return Math.max(8, Math.min(18, px * (zoom / 100)))
}, [imageNaturalH, zoom])
// Box zones in percent for clamping cell positions in overlay mode
const boxZonesPct = useMemo(() =>
parentZones
.filter(z => z.zone_type === 'box' && z.box)
.map(z => {
const imgH = imageNaturalSize?.h || 1
return {
topPct: (z.box!.y / imgH) * 100,
bottomPct: ((z.box!.y + z.box!.height) / imgH) * 100,
}
}),
[parentZones, imageNaturalSize]
)
if (!sessionId) {
return <div className="text-center py-12 text-gray-400">Bitte zuerst eine Session auswaehlen.</div>
}
@@ -476,20 +490,6 @@ export function StepReconstruction({ sessionId, onNext }: StepReconstructionProp
)
}
// Box zones in percent for clamping cell positions in overlay mode
const boxZonesPct = useMemo(() =>
parentZones
.filter(z => z.zone_type === 'box' && z.box)
.map(z => {
const imgH = imageNaturalSize?.h || 1
return {
topPct: (z.box!.y / imgH) * 100,
bottomPct: ((z.box!.y + z.box!.height) / imgH) * 100,
}
}),
[parentZones, imageNaturalSize]
)
// Clamp cell positions so they don't overlap with box zones
const adjustCellForBoxZones = (
bboxPct: { x: number; y: number; w: number; h: number },