refactor(react): add generics to useStoreApi

This commit is contained in:
moklick
2024-02-19 10:45:48 +01:00
parent 7bc9558631
commit 07ddd97650
4 changed files with 12 additions and 10 deletions
@@ -63,7 +63,7 @@ function MiniMapComponent<NodeType extends Node = Node>({
zoomStep = 10,
offsetScale = 5,
}: MiniMapProps<NodeType>) {
const store = useStoreApi();
const store = useStoreApi<NodeType>();
const svg = useRef<SVGSVGElement>(null);
const { boundingRect, viewBB, rfId, panZoom, translateExtent, flowWidth, flowHeight } = useStore(selector, shallow);
const elementWidth = (style?.width as number) ?? defaultWidth;
@@ -120,7 +120,7 @@ function MiniMapComponent<NodeType extends Node = Node>({
const onSvgNodeClick = onNodeClick
? useCallback((event: MouseEvent, nodeId: string) => {
const node = store.getState().nodeLookup.get(nodeId)! as NodeType;
const node = store.getState().nodeLookup.get(nodeId)!;
onNodeClick(event, node);
}, [])
: undefined;