diff --git a/src/components/GraphvizParent.tsx b/src/components/GraphvizParent.tsx index 5fafb89..4074793 100644 --- a/src/components/GraphvizParent.tsx +++ b/src/components/GraphvizParent.tsx @@ -1,5 +1,5 @@ // React component code -import React, {useContext, useEffect, useRef, useState} from 'react'; +import {FC, RefObject, useContext, useEffect, useRef, useState} from 'react'; import {graphviz} from 'd3-graphviz'; import { generateDotString, @@ -21,12 +21,7 @@ interface GraphvizParentProps { minVisits: number; } -const GraphvizParent: React.FC = ({ - csvData, - filter, - selfLoops, - minVisits, - }) => { +const GraphvizParent: FC = ({csvData, filter, selfLoops, minVisits}) => { const [dotString, setDotString] = useState(null); const [filteredDotString, setFilteredDotString] = useState(null); const [topDotString, setTopDotString] = useState(null); @@ -145,14 +140,14 @@ const GraphvizParent: React.FC = ({ .on('end', () => { const svgElement = ref.current?.querySelector('svg'); if (svgElement) { - exportGraphAsPNG(svgElement, filename); + exportGraphAsPNG(ref, filename); } }); } }; // Export a graph as high-quality PNG - const exportGraphAsPNG = (graphRef: React.RefObject, filename: string) => { + const exportGraphAsPNG = (graphRef: RefObject, filename: string) => { if (!graphRef.current) return; const svgElement = graphRef.current.querySelector('svg'); @@ -215,8 +210,6 @@ const GraphvizParent: React.FC = ({ }, [filteredDotString]); - - return (