From 8d70c864601c1d4a1168dcc31f7aa53a7d596376 Mon Sep 17 00:00:00 2001 From: Jason Zhu Date: Mon, 29 May 2023 21:04:46 +1000 Subject: [PATCH] Fix all typescript type issues --- src/App.tsx | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 9353f00..14339ec 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -5,14 +5,19 @@ import ReactFlow, { applyEdgeChanges, applyNodeChanges, addEdge, + Node, + Edge, + NodeChange, + EdgeChange, + Connection, } from 'reactflow'; // we have to import the React Flow styles for it to work import 'reactflow/dist/style.css'; -const initialEdges = []; +const initialEdges: Edge[] = []; -const initialNodes = [ +const initialNodes: Node[] = [ { id: '1', data: { label: 'Hello' }, @@ -31,16 +36,19 @@ const Flow = () => { const [edges, setEdges] = useState(initialEdges); const onNodesChange = useCallback( - changes => setNodes(nds => applyNodeChanges(changes, nds)), + (changes: NodeChange[]) => + setNodes((nds: Node[]) => applyNodeChanges(changes, nds)), [], ); const onEdgesChange = useCallback( - changes => setEdges(eds => applyEdgeChanges(changes, eds)), + (changes: EdgeChange[]) => + setEdges((eds: Edge[]) => applyEdgeChanges(changes, eds)), [], ); const onConnect = useCallback( - params => setEdges(eds => addEdge(params, eds)), + (params: Edge | Connection) => + setEdges((eds: Edge[]) => addEdge(params, eds)), [], );