useNodeConnections()
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:Name | Type | Default |
---|---|---|
[0]?.id | string ID of the node, filled in automatically if used inside custom node. | |
[0]?.handleType | HandleType What type of handle connections do you want to observe? | |
[0]?.handleId | string 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. |
Last updated on