refactor(nodelookup): use as normale store item

This commit is contained in:
moklick
2021-11-04 14:03:22 +01:00
parent 1b390e103d
commit 5547b0d6cc
5 changed files with 26 additions and 28 deletions
+6 -2
View File
@@ -1,5 +1,6 @@
import React, { useEffect, useState, CSSProperties } from 'react';
import { useStore } from '../../store';
import { getBezierPath } from '../Edges/BezierEdge';
import { getSmoothStepPath } from '../Edges/SmoothStepEdge';
import {
@@ -12,8 +13,9 @@ import {
ConnectionLineComponent,
HandleType,
Node,
ReactFlowState,
} from '../../types';
import useNodeLookup from '../../hooks/useNodeLookup';
interface ConnectionLineProps {
connectionNodeId: ElementId;
connectionHandleId: ElementId | null;
@@ -27,6 +29,8 @@ interface ConnectionLineProps {
CustomConnectionLineComponent?: ConnectionLineComponent;
}
const selector = (s: ReactFlowState) => s.nodeLookup;
export default ({
connectionNodeId,
connectionHandleId,
@@ -39,7 +43,7 @@ export default ({
isConnectable,
CustomConnectionLineComponent,
}: ConnectionLineProps) => {
const nodeLookup = useNodeLookup();
const nodeLookup = useStore(selector);
const [sourceNode, setSourceNode] = useState<NodeLookupItem | null>(null);
const nodeId = connectionNodeId;
const handleId = connectionHandleId;