Skip to content

Commit 59b1a60

Browse files
authored
Simplify node click handling in MiniMap component
Refactor node click handler to directly use onNodeClick without ref.
1 parent 965ca70 commit 59b1a60

1 file changed

Lines changed: 2 additions & 9 deletions

File tree

  • packages/react/src/additional-components/MiniMap

‎packages/react/src/additional-components/MiniMap/MiniMap.tsx‎

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -141,17 +141,10 @@ function MiniMapComponent<NodeType extends Node = Node>({
141141
}
142142
: undefined;
143143

144-
/*
145-
* the handler is kept in a ref so that the callback identity stays stable for
146-
* the memoized minimap nodes while still calling the current onNodeClick
147-
*/
148-
const onNodeClickRef = useRef(onNodeClick);
149-
onNodeClickRef.current = onNodeClick;
150-
151144
const nodeClickHandler = useCallback((event: MouseEvent, nodeId: string) => {
152145
const node: NodeType = store.getState().nodeLookup.get(nodeId)!.internals.userNode;
153-
onNodeClickRef.current?.(event, node);
154-
}, []);
146+
onNodeClick?.(event, node);
147+
}, [onNodeClick]);
155148

156149
const onSvgNodeClick = onNodeClick ? nodeClickHandler : undefined;
157150

0 commit comments

Comments
 (0)