Add an optional 'MiniMapNode' field to 'MiniMapProps'.

This lets users supply a custom SVG node to render in the minimap instead of the default rectangle.
This commit is contained in:
Hayleigh Thompson
2023-03-09 14:25:23 +00:00
parent 46f3f81dc4
commit 1415ed003e
2 changed files with 6 additions and 2 deletions
+4 -1
View File
@@ -64,6 +64,9 @@ function MiniMap({
pannable = false,
zoomable = false,
ariaLabel = 'React Flow mini map',
// Rename the field to avoid clashes with the default `MiniMapNode` component.
// Fallback to that component if none is provided.
MiniMapNode: CustomMiniMapNode = MiniMapNode,
}: MiniMapProps) {
const store = useStoreApi();
const svg = useRef<SVGSVGElement>(null);
@@ -176,7 +179,7 @@ function MiniMap({
const { x, y } = getNodePositionWithOrigin(node, nodeOrigin).positionAbsolute;
return (
<MiniMapNode
<CustomMiniMapNode
key={node.id}
x={x}
y={y}