simplify code & useEffect instead of uselayoutEffect
This commit is contained in:
@@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user