refactor(examples): update types of some examples

This commit is contained in:
moklick
2022-04-25 11:08:24 +02:00
parent e4eb9d0b38
commit 90aca9d4e6
6 changed files with 37 additions and 19 deletions
+5 -7
View File
@@ -1,4 +1,4 @@
import { useCallback } from 'react';
import { useCallback, MouseEvent } from 'react';
import ReactFlow, {
Node,
@@ -36,7 +36,7 @@ const UseZoomPanHelperFlow = () => {
const { project, setCenter, zoomIn, zoomOut, fitView, addNodes, setNodes: setNodesHook } = useReactFlow();
const onPaneClick = useCallback(
(evt) => {
(evt: MouseEvent) => {
const projectedPosition = project({ x: evt.clientX, y: evt.clientY - 40 });
setNodes((nds) =>
@@ -53,8 +53,8 @@ const UseZoomPanHelperFlow = () => {
);
const onNodeClick = useCallback(
(_, element) => {
const { x, y } = element.position;
(_: MouseEvent, node: Node) => {
const { x, y } = node.position;
setCenter(x, y, { zoom: 1, duration: 1200 });
},
[setCenter]
@@ -72,9 +72,7 @@ const UseZoomPanHelperFlow = () => {
addNodes(newNode);
}, [addNodes]);
const onResetNodes = useCallback(() => {
setNodesHook(initialNodes);
}, [setNodesHook]);
const onResetNodes = useCallback(() => setNodesHook(initialNodes), [setNodesHook]);
return (
<ReactFlow