reconnectEdge()
A handy utility to update an existing Edge with new
properties. This searches your edge array for an edge with a matching id and updates its
properties with the connection you provide.
const onReconnect = useCallback(
(oldEdge: Edge, newConnection: Connection) => setEdges((els) => reconnectEdge(oldEdge, newConnection, els)),
[]
);Signature
Parameters
oldEdge: EdgeTypenewConnection.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 notnull, the id of the handle on the source node that this connection originates from.newConnection.targetHandle: string | nullWhen notnull, the id of the handle on the target node that this connection terminates at.edges: EdgeType[]options.shouldReplaceId?: booleanShould the id of the old edge be replaced with the new connection id.options.getEdgeId?: GetEdgeIdCustom function to generate edge IDs. If not provided, the defaultgetEdgeIdfunction is used.options.onError?: OnErrorCalled when edge validation fails. If not provided, a default dev warning is used.
Returns
EdgeType[]