Skip to Content
Vue Flow v2 is here and joins xyflow! Read more here →
ReferenceUtils

reconnectEdge()

Source on GitHub 

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:
NameTypeDefault
oldEdgeEdgeType
newConnection.sourcestring

The id of the node this connection originates from.

newConnection.targetstring

The id of the node this connection terminates at.

newConnection.sourceHandlestring | null

When not null, the id of the handle on the source node that this connection originates from.

newConnection.targetHandlestring | null

When not null, the id of the handle on the target node that this connection terminates at.

edgesEdgeType[]
options.shouldReplaceIdboolean

Should the id of the old edge be replaced with the new connection id.

true
options.getEdgeIdGetEdgeId

Custom function to generate edge IDs. If not provided, the default getEdgeId function is used.

options.onErrorOnError

Called when edge validation fails. If not provided, a default dev warning is used.

Returns:

Notes

  • By default the edge keeps its id. Pass shouldReplaceId to derive a new id from the new connection instead.