Skip to Content

reconnectEdge()

GitHub 上的源代码

¥Source on GitHub

一个方便的实用程序,用于使用新属性更新现有的 Edge。这会在你的边缘数组中搜索具有匹配 id 的边缘,并使用你提供的连接更新其属性。

¥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:
NameTypeDefault
oldEdgeEdgeType

The edge you want to update.

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[]

The array of all current edges.

options.shouldReplaceIdboolean

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

true
Returns:
EdgeType[]

The updated edges array.

Last updated on