From 9dbb5fa70841cca7c6f7ef8f7aa2df8a5c57fa66 Mon Sep 17 00:00:00 2001 From: Benjamin Admin Date: Tue, 10 Mar 2026 22:57:25 +0100 Subject: [PATCH] fix: useMemo vor Early Returns verschieben (Rules of Hooks) 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 --- .../ocr-pipeline/StepReconstruction.tsx | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/admin-lehrer/components/ocr-pipeline/StepReconstruction.tsx b/admin-lehrer/components/ocr-pipeline/StepReconstruction.tsx index dd4f117..ad374bb 100644 --- a/admin-lehrer/components/ocr-pipeline/StepReconstruction.tsx +++ b/admin-lehrer/components/ocr-pipeline/StepReconstruction.tsx @@ -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
Bitte zuerst eine Session auswaehlen.
} @@ -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 },