diff --git a/examples/react/src/examples/UseNodesData/ResultNode.tsx b/examples/react/src/examples/UseNodesData/ResultNode.tsx index 38508b7a..ac9777dd 100644 --- a/examples/react/src/examples/UseNodesData/ResultNode.tsx +++ b/examples/react/src/examples/UseNodesData/ResultNode.tsx @@ -1,9 +1,9 @@ -import { memo, useEffect } from 'react'; +import { memo } from 'react'; import { Handle, Position, useHandleConnections, useNodesData } from '@xyflow/react'; function ResultNode() { const connections = useHandleConnections({ - handleType: 'target', + type: 'target', }); const nodesData = useNodesData(connections.map((connection) => connection.source)); diff --git a/examples/react/src/examples/UseNodesData/UppercaseNode.tsx b/examples/react/src/examples/UseNodesData/UppercaseNode.tsx index 06cf84a8..438c25cc 100644 --- a/examples/react/src/examples/UseNodesData/UppercaseNode.tsx +++ b/examples/react/src/examples/UseNodesData/UppercaseNode.tsx @@ -3,7 +3,7 @@ import { Position, NodeProps, useUpdateNodeData, Handle, useHandleConnections, u function UppercaseNode({ id }: NodeProps) { const connections = useHandleConnections({ - handleType: 'target', + type: 'target', }); const nodeData = useNodesData(connections[0]?.source); const updateNodeData = useUpdateNodeData(); diff --git a/packages/react/src/hooks/useHandleConnections.ts b/packages/react/src/hooks/useHandleConnections.ts index 58987aec..c9a026d9 100644 --- a/packages/react/src/hooks/useHandleConnections.ts +++ b/packages/react/src/hooks/useHandleConnections.ts @@ -5,9 +5,9 @@ import { useStore } from './useStore'; import { useNodeId } from '../contexts/NodeIdContext'; type useHandleConnectionsParams = { - handleType: HandleType; + type: HandleType; + id?: string | null; nodeId?: string; - handleId?: string | null; onConnect?: (connections: Connection[]) => void; onDisconnect?: (connections: Connection[]) => void; }; @@ -16,16 +16,16 @@ type useHandleConnectionsParams = { * Hook to check if a is connected to another and get the connections. * * @public - * @param param.handleType - 'source' or 'target' - * @param param.handleId - the handle id (this is only needed if the node has multiple handles of the same type) + * @param param.type - handle type 'source' or 'target' + * @param param.id - the handle id (this is only needed if the node has multiple handles of the same type) * @param param.nodeId - node id - if not provided, the node id from the NodeIdContext is used * @param param.onConnect - gets called when a connection is established * @param param.onDisconnect - gets called when a connection is removed * @returns an array with connections */ export function useHandleConnections({ - handleType, - handleId = null, + type, + id = null, nodeId, onConnect, onDisconnect, @@ -35,7 +35,7 @@ export function useHandleConnections({ const currentNodeId = nodeId || _nodeId; const connections = useStore( - (state) => state.connectionLookup.get(`${currentNodeId}-${handleType}-${handleId}`), + (state) => state.connectionLookup.get(`${currentNodeId}-${type}-${id}`), areConnectionMapsEqual );