update useNodeConnections

This commit is contained in:
peterkogo
2025-01-09 16:15:10 +01:00
11 changed files with 98 additions and 78 deletions
@@ -12,7 +12,7 @@ function CustomHandle({ nodeId, ...handleProps }: HandleProps & { nodeId: string
[nodeId]
);
const connections = useNodeConnections({
type: handleProps.type,
handleType: handleProps.type,
handleId: handleProps.id,
onConnect,
onDisconnect,
@@ -15,7 +15,7 @@ function CustomHandle({ nodeId, ...handleProps }: HandleProps & { nodeId: string
[nodeId]
);
const connections = useNodeConnections({
type: handleProps.type,
handleType: handleProps.type,
handleId: handleProps.id,
onConnect,
onDisconnect,
@@ -4,7 +4,7 @@ import { isTextNode, type MyNode } from '.';
function ResultNode() {
const connections = useNodeConnections({
type: 'target',
handleType: 'target',
});
const nodesData = useNodesData<MyNode>(connections.map((connection) => connection.source));
const textNodes = nodesData.filter(isTextNode);
@@ -5,7 +5,7 @@ import { isTextNode, type TextNode, type MyNode } from '.';
function UppercaseNode({ id }: NodeProps) {
const { updateNodeData } = useReactFlow();
const connections = useNodeConnections({
type: 'target',
handleType: 'target',
});
const nodesData = useNodesData<MyNode>(connections[0]?.source);
const textNode = isTextNode(nodesData) ? nodesData : null;