參考文檔工具

reconnectEdge()

GitHub 上的原始碼

一個方便的工具,用於更新現有的 Edge,使用新的屬性。此工具會在您的邊緣陣列中搜尋具有相符 id 的邊緣,並使用您提供的連線更新其屬性。

const onReconnect = useCallback(
  (oldEdge: Edge, newConnection: Connection) => setEdges((els) => reconnectEdge(oldEdge, newConnection, els)),
  []
);

簽名

#參數
#edge
Edge
#connection
Connection
#edges
Edge[]
#options?
物件
#options.shouldReplaceId
布林值
#回傳
Edge[]