Skip to content

Commit 79fcb26

Browse files
committed
apply tim's suggestion
1 parent 106843b commit 79fcb26

3 files changed

Lines changed: 7 additions & 10 deletions

File tree

src/components/AffectedComponent.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
PURLInspectResponse,
77
VulnInPackage,
88
} from "@/types/api/api";
9-
import { FunctionComponent, useMemo, useState } from "react";
9+
import { FunctionComponent, useEffect, useMemo, useState } from "react";
1010
import EcosystemImage from "./common/EcosystemImage";
1111
import { beautifyPurl, extractVersion } from "@/utils/common";
1212
import { Badge } from "./ui/badge";
@@ -45,7 +45,7 @@ const AffectedComponentDetails: FunctionComponent<{
4545
revalidateOnReconnect: false,
4646
});
4747

48-
useSWR(data ? `matched-cve-${vuln.cveID}` : null, () => {
48+
useEffect(() => {
4949
if (data) {
5050
const matchedCVE = data.vulns.find(
5151
(vulnInPkg) => vuln.cveID === vulnInPkg.CVEID,
@@ -54,8 +54,7 @@ const AffectedComponentDetails: FunctionComponent<{
5454
setActiveCVE(matchedCVE);
5555
}
5656
}
57-
return null;
58-
});
57+
}, [data, vuln.cveID]);
5958

6059
if (isLoading) {
6160
return (

src/components/DependencyGraph.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,8 @@ const DependencyGraph: FunctionComponent<{
135135

136136
// Compute direct dependencies with available patches
137137
const directDepsWithPatchesRef = useRef<Set<string>>(new Set());
138-
useMemo(() => {
139-
directDepsWithPatchesRef.current.clear();
138+
directDepsWithPatchesRef.current = useMemo(() => {
139+
const deps = new Set<string>();
140140
vulns.forEach((vuln) => {
141141
// Check if this is a DetailedDependencyVulnDTO with directDependencyFixedVersion
142142
const detailedVuln = vuln as any;
@@ -146,9 +146,10 @@ const DependencyGraph: FunctionComponent<{
146146
detailedVuln.vulnerabilityPath.length > 0
147147
) {
148148
// The direct dependency is the first element in the path
149-
directDepsWithPatchesRef.current.add(detailedVuln.vulnerabilityPath[0]);
149+
deps.add(detailedVuln.vulnerabilityPath[0]);
150150
}
151151
});
152+
return deps;
152153
}, [vulns]);
153154

154155
if (childCountMapRef.current.size === 0) {

src/components/Quickfix.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,6 @@ function renderQuickFixText(
9797
const Quickfix: FunctionComponent<{ vuln: DetailedDependencyVulnDTO }> = ({
9898
vuln,
9999
}) => {
100-
// console.log("Quickfix component received vuln:", vuln);
101-
console.log(vuln.vulnerabilityPath[0]);
102-
103100
const componentPurl = vuln.componentPurl;
104101
const directDependencyFixedVersion =
105102
vuln.directDependencyFixedVersion ?? undefined;

0 commit comments

Comments
 (0)