useHandleConnections
此钩子返回特定句柄或句柄类型上的连接数组。
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"您想观察哪种类型的句柄连接? |
# id? | string句柄的 ID |
# nodeId? | string节点的 ID,如果在自定义节点中使用,则会自动填充 |
# onConnect? | (connections: Connection[]) => void |
# onDisconnect? | (connections: Connection[]) => void |
#返回值 | |
HandleConnection[] |