addEdge()
The addEdge util is a convenience function to add a new
Edge to an array of edges. It also validates the edge
so you don’t add an invalid one or duplicate an existing connection.
import { addEdge } from '@xyflow/vue';
function onConnect(connection) {
edges.value = addEdge(connection, edges.value);
}Signature
Parameters:| Name | Type | Default |
|---|---|---|
edgeParams | EdgeType | Connection | |
edges | EdgeType[] | |
options.getEdgeId | GetEdgeIdCustom function to generate edge IDs. If not provided, the default | |
options.onError | OnErrorCalled when edge validation fails. If not provided, a default dev warning is used. |
EdgeType[]Notes
- If an edge with the same
sourceandtargetalready exists (and the samesourceHandle/targetHandlewhen set),addEdgewon’t add another one — even if theiddiffers.