diff --git a/apps/ai-game-creator-shell/src/view/ui-editor/components/preview/useNodeTransformInteraction.ts b/apps/ai-game-creator-shell/src/view/ui-editor/components/preview/useNodeTransformInteraction.ts index 3208dfba8..d2ac9e82a 100644 --- a/apps/ai-game-creator-shell/src/view/ui-editor/components/preview/useNodeTransformInteraction.ts +++ b/apps/ai-game-creator-shell/src/view/ui-editor/components/preview/useNodeTransformInteraction.ts @@ -100,15 +100,18 @@ export function useNodeTransformInteraction({ ) => void; }) { const activeGestureRef = useRef(null); + // Keep cleanup stable while still invoking the latest preview callback. + const onPreviewTransformRef = useRef(onPreviewTransform); + onPreviewTransformRef.current = onPreviewTransform; const cancelGesture = useCallback(() => { const gesture = activeGestureRef.current; if (gesture) { releasePointer(gesture.target, gesture.pointerId); - onPreviewTransform?.(gesture.nodeId, null); + onPreviewTransformRef.current?.(gesture.nodeId, null); } activeGestureRef.current = null; - }, [onPreviewTransform]); + }, []); useEffect(() => cancelGesture, [cancelGesture]);