Skip to content

Commit d295edd

Browse files
committed
[#noissue] Apply memoization to UrlSummaryColumn
1 parent dbfbbc7 commit d295edd

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

web-frontend/src/main/v3/packages/ui/src/components/URL/summary/UrlSummaryFetcher.tsx

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,22 @@ export const UrlSummaryFetcher = ({ className, type }: UrlSummaryFetcherProps) =
2323
orderBy,
2424
type,
2525
});
26-
const columns = summaryColumns({
27-
orderBy,
28-
isDesc,
29-
onClickColumnHeader: (key) => {
30-
if (orderBy === key) {
31-
setIsDesc(!isDesc);
32-
} else {
33-
setIsDesc(true);
34-
}
35-
36-
setOrderBy(key);
37-
},
38-
});
26+
const columns = React.useMemo(
27+
() =>
28+
summaryColumns({
29+
orderBy,
30+
isDesc,
31+
onClickColumnHeader: (key) => {
32+
if (orderBy === key) {
33+
setIsDesc((prev) => !prev);
34+
} else {
35+
setIsDesc(true);
36+
}
37+
setOrderBy(key);
38+
},
39+
}),
40+
[orderBy, isDesc],
41+
);
3942

4043
const getRowSelectionInfo = () => {
4144
const selectedRowIndex =

0 commit comments

Comments
 (0)