Skip to content

How Can I make custom edge like default step type? #3190

Answered by bcakmakoglu
Distrect asked this question in Q&A
Discussion options

You must be logged in to vote

React Flow provides a utility called getSmoothStepPath, just like getBezierPath, that you can use.

import React from 'react';
import { BaseEdge, EdgeProps, getSmoothStepPath } from 'reactflow';

export default function CustomEdge({
  id,
  sourceX,
  sourceY,
  targetX,
  targetY,
  sourcePosition,
  targetPosition,
  style = {},
  markerEnd,
}: EdgeProps) {
  const [edgePath, labelX, labelY] = getSmoothStepPath({
    sourceX,
    sourceY,
    sourcePosition,
    targetX,
    targetY,
    targetPosition,
  });

  return <BaseEdge path={edgePath} markerEnd={markerEnd} style={style} />
}

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
2 replies
@bcakmakoglu
Comment options

@Distrect
Comment options

Answer selected by Distrect
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants