Why can not access 'type' in EdgeProps when i create custom edge component using '@xyflow/react'? #4595
-
Hi, xyflow team :) First, thank you for making amazing graph draw library. it is very useful to me. I could not access 'type' of edge during creating custom edge component like following. const CustomEdgeComponent = (
props: EdgeProps<CustomEdgeType>
) => {
const type = props.type; // Problem: EdgeProps do not allow to access 'type' data.
...
} Question 1) Is there alternative way to get edge's type? if no special reason about hiding I hope to add xyflow/packages/react/src/types/edges.ts Line 109 in 9b768b2 Incompatible type mismatchI'd like to share additional strange point.
xyflow/packages/react/src/types/general.ts Lines 42 to 52 in e55b2ad FYI) I tried to apply HOC pattern to CustomEdgeComponent for adding,removing edit ability in case by case import { EdgeTypes } from "'@xyflow/react"
const edgeTypes: EdgeTypes = {
customEdge: withEditable(CustomEdge), // Typescript error b/c EdgeTypes required {data: any, type: any}
}
const CustomEdge = (props: EdgeProps) => {...}
type CustomEdgeComponentProps = ComponentProps<typeof GraphEdgeComponent>
const withEditable = (EdgeComponent: ComponentType<CustomEdgeComponentProps>) => { ... } Above code is summary in my situation. But, i hoped graceful solution |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
An alternative way to get the edge type would be to use const edge = getEdge(edgeId)
const type = edge.type |
Beta Was this translation helpful? Give feedback.
An alternative way to get the edge type would be to use
getEdge