Skip to Content
参考手册钩子

useNodeConnections()

GitHub 上的源代码

¥Source on GitHub

此钩子返回特定节点、句柄类型 (‘source’、‘target’) 或句柄 ID 上的连接数组。

¥This hook returns an array of connections on a specific node, handle type (‘source’, ‘target’) or handle ID.

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

签名

¥Signature

Parameters:
NameTypeDefault
[0]?.idstring

ID of the node, filled in automatically if used inside custom node.

[0]?.handleTypeHandleType

What type of handle connections do you want to observe?

[0]?.handleIdstring

Filter by handle id (this is only needed if the node has multiple handles of the same type).

[0]?.onConnect(connections: Connection[]) => void

Gets called when a connection is established.

[0]?.onDisconnect(connections: Connection[]) => void

Gets called when a connection is removed.

Returns:
NodeConnection[]

An array with connections.

Last updated on