Skip to Content
参考手册钩子

useHandleConnections()

Warning

useHandleConnections 已弃用,取而代之的是功能更强大的 useNodeConnections

¥useHandleConnections is deprecated in favor of the more capable useNodeConnections.

GitHub 上的源代码 

¥Source on GitHub 

此钩子返回特定句柄或句柄类型的数组连接。

¥This hook returns an array connections on a specific handle or handle type.

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> ); }

签名

¥Signature

Parameters:
NameTypeDefault
[0].typeHandleType

What type of handle connections do you want to observe?

[0].idstring | null

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

[0].nodeIdstring

If node id is not provided, the node id from the NodeIdContext is used.

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

An array with handle connections.

Last updated on