@@ -558,8 +558,21 @@ export function useActions(
558
558
state . hooks . edgesChange . trigger ( changes )
559
559
}
560
560
561
- const updateEdge : Actions [ 'updateEdge' ] = ( oldEdge , newConnection , shouldReplaceId = true ) =>
562
- updateEdgeAction ( oldEdge , newConnection , state . edges , findEdge , shouldReplaceId , state . hooks . error . trigger )
561
+ const updateEdge : Actions [ 'updateEdge' ] = ( oldEdge , newConnection , shouldReplaceId = true ) => {
562
+ return updateEdgeAction ( oldEdge , newConnection , state . edges , findEdge , shouldReplaceId , state . hooks . error . trigger )
563
+ }
564
+
565
+ const updateEdgeData : Actions [ 'updateEdgeData' ] = ( id , dataUpdate , options = { replace : false } ) => {
566
+ const edge = findEdge ( id )
567
+
568
+ if ( ! edge ) {
569
+ return
570
+ }
571
+
572
+ const nextData = typeof dataUpdate === 'function' ? dataUpdate ( edge ) : dataUpdate
573
+
574
+ edge . data = options . replace ? nextData : { ...edge . data , ...nextData }
575
+ }
563
576
564
577
const applyNodeChanges : Actions [ 'applyNodeChanges' ] = ( changes ) => {
565
578
return applyChanges ( changes , state . nodes )
@@ -591,14 +604,15 @@ export function useActions(
591
604
}
592
605
593
606
const updateNodeData : Actions [ 'updateNodeData' ] = ( id , dataUpdate , options = { replace : false } ) => {
594
- updateNode (
595
- id ,
596
- ( node ) => {
597
- const nextData = typeof dataUpdate === 'function' ? dataUpdate ( node ) : dataUpdate
598
- return options . replace ? { ...node , data : nextData } : { ...node , data : { ...node . data , ...nextData } }
599
- } ,
600
- options ,
601
- )
607
+ const node = findNode ( id )
608
+
609
+ if ( ! node ) {
610
+ return
611
+ }
612
+
613
+ const nextData = typeof dataUpdate === 'function' ? dataUpdate ( node ) : dataUpdate
614
+
615
+ node . data = options . replace ? nextData : { ...node . data , ...nextData }
602
616
}
603
617
604
618
const startConnection : Actions [ 'startConnection' ] = ( startHandle , position , event , isClick = false ) => {
@@ -897,6 +911,7 @@ export function useActions(
897
911
findNode,
898
912
findEdge,
899
913
updateEdge,
914
+ updateEdgeData,
900
915
updateNode,
901
916
updateNodeData,
902
917
applyEdgeChanges,
0 commit comments