Factor out rendering of table body to a memoized component
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import type { ChangeEvent } from "react";
|
import type { ChangeEvent } from "react";
|
||||||
import { Fragment, useMemo, useRef, useState } from "react";
|
import { Fragment, memo, useMemo, useRef, useState } from "react";
|
||||||
import type {
|
import type {
|
||||||
SetPerformanceComparisonQueries,
|
SetPerformanceComparisonQueries,
|
||||||
ToComparePerformanceViewMessage,
|
ToComparePerformanceViewMessage,
|
||||||
@@ -577,15 +577,12 @@ function ComparePerformanceWithData(props: {
|
|||||||
</HeaderTR>
|
</HeaderTR>
|
||||||
</thead>
|
</thead>
|
||||||
</Table>
|
</Table>
|
||||||
{rowGroups.map((rowGroup, rowGroupIndex) => (
|
<PredicateTable
|
||||||
<PredicateRowGroup
|
rowGroups={rowGroups}
|
||||||
key={rowGroupIndex}
|
rowGroupNames={rowGroupNames}
|
||||||
renderedName={rowGroupNames[rowGroupIndex]}
|
comparison={comparison}
|
||||||
rowGroup={rowGroup}
|
metric={metric}
|
||||||
comparison={comparison}
|
/>
|
||||||
metric={metric}
|
|
||||||
/>
|
|
||||||
))}
|
|
||||||
<Table>
|
<Table>
|
||||||
<tfoot>
|
<tfoot>
|
||||||
<tr key="spacing">
|
<tr key="spacing">
|
||||||
@@ -606,6 +603,28 @@ function ComparePerformanceWithData(props: {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface PredicateTableProps {
|
||||||
|
rowGroups: RowGroup[];
|
||||||
|
rowGroupNames: React.ReactNode[];
|
||||||
|
comparison: boolean;
|
||||||
|
metric: Metric;
|
||||||
|
}
|
||||||
|
|
||||||
|
function PredicateTableRaw(props: PredicateTableProps) {
|
||||||
|
const { comparison, metric, rowGroupNames, rowGroups } = props;
|
||||||
|
return rowGroups.map((rowGroup, rowGroupIndex) => (
|
||||||
|
<PredicateRowGroup
|
||||||
|
key={rowGroupIndex}
|
||||||
|
renderedName={rowGroupNames[rowGroupIndex]}
|
||||||
|
rowGroup={rowGroup}
|
||||||
|
comparison={comparison}
|
||||||
|
metric={metric}
|
||||||
|
/>
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
const PredicateTable = memo(PredicateTableRaw);
|
||||||
|
|
||||||
interface PredicateRowGroupProps {
|
interface PredicateRowGroupProps {
|
||||||
renderedName: React.ReactNode;
|
renderedName: React.ReactNode;
|
||||||
rowGroup: RowGroup;
|
rowGroup: RowGroup;
|
||||||
|
|||||||
Reference in New Issue
Block a user