參考Hooks

useHandleConnections

在 GitHub 上查看原始碼

此 Hook 會在特定 handle 或 handle 類型上傳回連線陣列。

import { useHandleConnections } from '@xyflow/react';
 
export default function () {
  const connections = useHandleConnections({ type: 'target', id: 'my-handle' });
 
  return (
    <div>There are currently {connections.length} incoming connections!</div>
  );
}

簽名

#參數
#type
"source" | "target"
您想觀察哪種 handle 連線?
#id?
字串
handle 的 ID
#nodeId?
字串
節點的 ID,如果用於自訂節點內,則會自動填入
#onConnect?
(連線: Connection[]) => void
#onDisconnect?
(連線: Connection[]) => void
#回傳
HandleConnection[]