Skip to Content
You are viewing the v12 docs of React Flow. You can find the latest version here.
ReferenceUtils

getConnectedEdges()

Source on GitHub 

This utility filters an array of edges, keeping only those where either the source or target node is present in the given array of nodes.

import { getConnectedEdges } from '@xyflow/react'; const nodes = [ { id: 'a', position: { x: 0, y: 0 } }, { id: 'b', position: { x: 100, y: 0 } }, ]; const edges = [ { id: 'a->c', source: 'a', target: 'c' }, { id: 'c->d', source: 'c', target: 'd' }, ]; const connectedEdges = getConnectedEdges(nodes, edges); // => [{ id: 'a->c', source: 'a', target: 'c' }]

Signature

Parameters:
NameTypeDefault
nodesNodeType[]

Nodes you want to get the connected edges for.

edgesEdgeType[]

All edges.

Returns:
Last updated on