Skip to content

Commit 93edb6f

Browse files
authored
fix: memoize inputs to fix performance issues (#1291)
Fixes HDX-2644 Fixes #1288
1 parent bb3539d commit 93edb6f

File tree

3 files changed

+24
-15
lines changed

3 files changed

+24
-15
lines changed

.changeset/angry-scissors-flow.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@hyperdx/app": patch
3+
---
4+
5+
fix: memoize inputs to fix text input performance

packages/app/src/DBSearchPage.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,9 +1208,12 @@ function DBSearchPage() {
12081208
);
12091209
// Parse the orderBy string into a SortingState. We need the string
12101210
// version in other places so we keep this parser separate.
1211-
const orderByConfig = parseAsSortingStateString.parse(
1212-
searchedConfig.orderBy ?? '',
1213-
);
1211+
const initialSortBy = useMemo(() => {
1212+
const orderBy = parseAsSortingStateString.parse(
1213+
searchedConfig.orderBy ?? '',
1214+
);
1215+
return orderBy ? [orderBy] : [];
1216+
}, [searchedConfig.orderBy]);
12141217

12151218
const handleTimeRangeSelect = useCallback(
12161219
(d1: Date, d2: Date) => {
@@ -1824,7 +1827,7 @@ function DBSearchPage() {
18241827
denoiseResults={denoiseResults}
18251828
collapseAllRows={collapseAllRows}
18261829
onSortingChange={onSortingChange}
1827-
initialSortBy={orderByConfig ? [orderByConfig] : []}
1830+
initialSortBy={initialSortBy}
18281831
/>
18291832
)}
18301833
</>

packages/app/src/components/DBSqlRowTableWithSidebar.tsx

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,17 @@ export default function DBSqlRowTableWithSideBar({
7474
setRowId(null);
7575
setRowSource(null);
7676
}, [setRowId, setRowSource]);
77+
const renderRowDetails = useCallback(
78+
(r: { [key: string]: unknown }) => {
79+
if (!sourceData) {
80+
return <div className="p-3 text-muted">Loading...</div>;
81+
}
82+
return (
83+
<RowOverviewPanelWrapper source={sourceData} rowId={r.id as string} />
84+
);
85+
},
86+
[sourceData],
87+
);
7788

7889
return (
7990
<RowSidePanelContext.Provider value={context ?? {}}>
@@ -97,17 +108,7 @@ export default function DBSqlRowTableWithSideBar({
97108
onSortingChange={onSortingChange}
98109
denoiseResults={denoiseResults}
99110
initialSortBy={initialSortBy}
100-
renderRowDetails={r => {
101-
if (!sourceData) {
102-
return <div className="p-3 text-muted">Loading...</div>;
103-
}
104-
return (
105-
<RowOverviewPanelWrapper
106-
source={sourceData}
107-
rowId={r.id as string}
108-
/>
109-
);
110-
}}
111+
renderRowDetails={renderRowDetails}
111112
onScroll={onScroll}
112113
onError={onError}
113114
onExpandedRowsChange={onExpandedRowsChange}

0 commit comments

Comments
 (0)