simplify code & useEffect instead of uselayoutEffect

This commit is contained in:
peterkogo
2026-02-09 07:57:41 +01:00
parent ee53f8baf7
commit cb41f444eb

View File

@@ -3,7 +3,6 @@ import { XYDrag, type XYDragInstance } from '@xyflow/system';
import { handleNodeClick } from '../components/Nodes/utils'; import { handleNodeClick } from '../components/Nodes/utils';
import { useStoreApi } from './useStore'; import { useStoreApi } from './useStore';
import { useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect';
type UseDragParams = { type UseDragParams = {
nodeRef: RefObject<HTMLDivElement>; nodeRef: RefObject<HTMLDivElement>;
@@ -52,13 +51,8 @@ export function useDrag({
}); });
}, []); }, []);
useIsomorphicLayoutEffect(() => { useEffect(() => {
if (disabled) { if (disabled || !nodeRef.current || !xyDrag.current) {
xyDrag.current?.destroy();
return;
}
if (!nodeRef.current || !xyDrag.current) {
return; return;
} }