useEdge(id)
This hook returns the current edge with the specified ID. Components that use this hook will re-render whenever the edge changes, including when it is selected or moved.
import { useEdge } from '@xyflow/react';
export default function ({ id }) {
const edge = useEdge(id);
return <div>The current edge ID is {edge?.id}</div>;
}Signature
Parameters:| Name | Type | Default |
|---|---|---|
id | stringThe id of the edge to return. |
EdgeType | undefinedTypeScript
This hook accepts a generic type argument of custom edge types. See this section in our TypeScript guide for more information.
const edge = useEdge<CustomEdgeType>(id);