Skip to content

Commit 27db76e

Browse files
authored
Merge pull request #3818 from asgerf/asgerf/simplify-conditional-hooks
Compare-perf: Check for nullness of 'data' in a separate component
2 parents 655a734 + 60216f9 commit 27db76e

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

extensions/ql-vscode/src/view/compare-performance/ComparePerformance.tsx

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -359,14 +359,23 @@ export function ComparePerformance(_: Record<string, never>) {
359359
[setData],
360360
);
361361

362-
const datasets = useMemo(
363-
() =>
364-
data == null
365-
? undefined
366-
: {
367-
from: new ComparisonDataset(data.from),
368-
to: new ComparisonDataset(data.to),
369-
},
362+
if (!data) {
363+
return <div>Loading performance comparison...</div>;
364+
}
365+
366+
return <ComparePerformanceWithData data={data} />;
367+
}
368+
369+
function ComparePerformanceWithData(props: {
370+
data: SetPerformanceComparisonQueries;
371+
}) {
372+
const { data } = props;
373+
374+
const { from, to } = useMemo(
375+
() => ({
376+
from: new ComparisonDataset(data.from),
377+
to: new ComparisonDataset(data.to),
378+
}),
370379
[data],
371380
);
372381

@@ -380,12 +389,6 @@ export function ComparePerformance(_: Record<string, never>) {
380389

381390
const [metric, setMetric] = useState<Metric>(metrics.tuples);
382391

383-
if (!datasets) {
384-
return <div>Loading performance comparison...</div>;
385-
}
386-
387-
const { from, to } = datasets;
388-
389392
const nameSet = new Set(from.data.names);
390393
for (const name of to.data.names) {
391394
nameSet.add(name);

0 commit comments

Comments
 (0)