()
| 35 | * ``` |
| 36 | */ |
| 37 | export function useRemoveElement() { |
| 38 | const graph = useGraph(); |
| 39 | return useCallback( |
| 40 | (id: dia.Cell.ID) => { |
| 41 | const cell = graph.getCell(id); |
| 42 | if (!cell.isElement()) { |
| 43 | return; |
| 44 | } |
| 45 | if (cell) { |
| 46 | cell.remove(); |
| 47 | } |
| 48 | }, |
| 49 | [graph] |
| 50 | ); |
| 51 | } |
| 52 | |
| 53 | /** |
| 54 | * A custom hook that removes a link from the graph by its ID. |