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

Preventing Cycles

In the validation example, we saw how to use the isValidConnection callback to prevent certain connections from being created. This example shows how to use the getOutgoers util to check if a new connection would cause a cycle in the flow.

export const nodes = [ { id: '1', position: { x: 0, y: 9 }, data: { label: 'A' }, }, { id: '2', position: { x: 125, y: 125 }, data: { label: 'B' }, }, { id: '3', position: { x: 0, y: 250 }, data: { label: 'C' }, }, { id: '4', position: { x: -125, y: 125 }, data: { label: 'C' }, }, ]; export const edges = [ { id: 'e1-2', source: '1', target: '2', }, ];
Last updated on