reconnectEdge()
The reconnectEdge util takes an existing Edge, a new
Connection, and the current edges, and returns a
new array with that edge reconnected to the new source/target. Use it from the
@reconnect handler to persist a reconnection.
import { reconnectEdge } from '@xyflow/vue';
function onReconnect(oldEdge, newConnection) {
edges.value = reconnectEdge(oldEdge, newConnection, edges.value);
}Signature
Parameters:| Name | Type | Default |
|---|---|---|
oldEdge | EdgeType | |
newConnection.source | stringThe id of the node this connection originates from. | |
newConnection.target | stringThe id of the node this connection terminates at. | |
newConnection.sourceHandle | string | nullWhen not | |
newConnection.targetHandle | string | nullWhen not | |
edges | EdgeType[] | |
options.shouldReplaceId | booleanShould the id of the old edge be replaced with the new connection id. | true |
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
- By default the edge keeps its
id. PassshouldReplaceIdto derive a new id from the new connection instead.