useOnSelectionChange
This hook lets you listen to selection changes.
caution
This hook can only be used if the component that uses it is wrapped with a ReactFlowProvider
or if it's a child of the <ReactFlow />
component.
Usage
import { ReactFlow, useOnSelectionChange } from 'reactflow';
function SelectionChangeLogger() {
useOnSelectionChange({
onChange: ({ nodes, edges }) => console.log('changed selection', nodes, edges),
});
return null;
}
Typescript
useOnSelectionChange({
onChange?: ({ nodes, edges }: { nodes: Node[], edges: Edge[] }):void => {console.log('changed selection', nodes, edges)},
}): void