remove redundant connectionLookup entries

This commit is contained in:
peterkogo
2025-01-07 14:18:05 +01:00
parent b601d385f3
commit b2d1844c0f
6 changed files with 37 additions and 11 deletions
@@ -32,7 +32,7 @@ type useHandleConnectionsParams = {
*/
export function useHandleConnections({
type,
id = null,
id,
nodeId,
onConnect,
onDisconnect,
@@ -47,7 +47,7 @@ export function useHandleConnections({
const prevConnections = useRef<Map<string, HandleConnection> | null>(null);
const connections = useStore(
(state) => state.connectionLookup.get(`${currentNodeId}-${type}-${id}`),
(state) => state.connectionLookup.get(`${currentNodeId}-${type}${id ? `-${id}` : ''}`),
areConnectionMapsEqual
);
+8 -1
View File
@@ -239,7 +239,14 @@ export function useReactFlow<NodeType extends Node = Node, EdgeType extends Edge
Array.from(
store
.getState()
.connectionLookup.get(`${nodeId}-${type}-${id ?? null}`)
.connectionLookup.get(`${nodeId}-${type}${id ? `-${id}` : ''}`)
?.values() ?? []
),
getNodeConnections: ({ type, handleId, nodeId }) =>
Array.from(
store
.getState()
.connectionLookup.get(`${nodeId}${type ? (handleId ? `-${type}-${handleId}` : `-${type}`) : ''}`)
?.values() ?? []
),
};