fix(connectionRadius): pass prop to store

This commit is contained in:
moklick
2023-01-26 10:24:58 +01:00
parent 6dbc529b7f
commit 3078777b28
3 changed files with 7 additions and 3 deletions
@@ -1,4 +1,4 @@
import React, { FC, useMemo, CSSProperties } from 'react';
import { FC, useMemo, CSSProperties } from 'react';
import { EdgeProps, useStore, getBezierPath, ReactFlowState } from 'reactflow';
import { getEdgeParams } from './utils';
@@ -17,7 +17,7 @@ const FloatingEdge: FC<EdgeProps> = ({ id, source, target, style }) => {
const { sx, sy, tx, ty, sourcePos, targetPos } = getEdgeParams(sourceNode, targetNode);
const d = getBezierPath({
const [path] = getBezierPath({
sourceX: sx,
sourceY: sy,
sourcePosition: sourcePos,
@@ -28,7 +28,7 @@ const FloatingEdge: FC<EdgeProps> = ({ id, source, target, style }) => {
return (
<g className="react-flow__connection">
<path id={id} className="react-flow__edge-path" d={d} style={style as CSSProperties} />
<path id={id} className="react-flow__edge-path" d={path} style={style as CSSProperties} />
</g>
);
};
@@ -48,6 +48,7 @@ type StoreUpdaterProps = Pick<
| 'autoPanOnConnect'
| 'autoPanOnNodeDrag'
| 'onError'
| 'connectionRadius'
> & { rfId: string };
const selector = (s: ReactFlowState) => ({
@@ -125,6 +126,7 @@ const StoreUpdater = ({
autoPanOnConnect,
autoPanOnNodeDrag,
onError,
connectionRadius,
}: StoreUpdaterProps) => {
const {
setNodes,
@@ -181,6 +183,7 @@ const StoreUpdater = ({
useDirectStoreUpdater('autoPanOnConnect', autoPanOnConnect, store.setState);
useDirectStoreUpdater('autoPanOnNodeDrag', autoPanOnNodeDrag, store.setState);
useDirectStoreUpdater('onError', onError, store.setState);
useDirectStoreUpdater('connectionRadius', connectionRadius, store.setState);
useStoreUpdater<Node[]>(nodes, setNodes);
useStoreUpdater<Edge[]>(edges, setEdges);
@@ -294,6 +294,7 @@ const ReactFlow = forwardRef<ReactFlowRefType, ReactFlowProps>(
autoPanOnConnect={autoPanOnConnect}
autoPanOnNodeDrag={autoPanOnNodeDrag}
onError={onError}
connectionRadius={connectionRadius}
/>
<SelectionListener onSelectionChange={onSelectionChange} />
{children}