Skip to content

Commit 5eb9f7f

Browse files
committed
fix(studio): clear zoom timers on NLEPreview unmount
settleTimerRef, hudTimerRef, and retiringTimerRef could fire after component unmount. Add cleanup effect to prevent stale callbacks.
1 parent e2ee804 commit 5eb9f7f

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

‎packages/studio/src/components/nle/NLEPreview.tsx‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,14 @@ export const NLEPreview = memo(function NLEPreview({
7676
originY: number;
7777
} | null>(null);
7878

79+
useEffect(() => {
80+
return () => {
81+
if (settleTimerRef.current) clearTimeout(settleTimerRef.current);
82+
if (hudTimerRef.current) clearTimeout(hudTimerRef.current);
83+
if (retiringTimerRef.current) clearTimeout(retiringTimerRef.current);
84+
};
85+
}, []);
86+
7987
const writeTransform = useCallback((state: PreviewZoomState) => {
8088
const stage = stageRef.current;
8189
if (!stage) return;

0 commit comments

Comments
 (0)