fix: memoize inputs to fix performance issues (#1291)

Fixes HDX-2644
Fixes #1288
This commit is contained in:
Aaron Knudtson 2025-10-27 15:53:18 +01:00 committed by GitHub
parent bb3539dd5d
commit 93edb6f84f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 24 additions and 15 deletions

View file

@ -0,0 +1,5 @@
---
"@hyperdx/app": patch
---
fix: memoize inputs to fix text input performance

View file

@ -1208,9 +1208,12 @@ function DBSearchPage() {
);
// Parse the orderBy string into a SortingState. We need the string
// version in other places so we keep this parser separate.
const orderByConfig = parseAsSortingStateString.parse(
searchedConfig.orderBy ?? '',
);
const initialSortBy = useMemo(() => {
const orderBy = parseAsSortingStateString.parse(
searchedConfig.orderBy ?? '',
);
return orderBy ? [orderBy] : [];
}, [searchedConfig.orderBy]);
const handleTimeRangeSelect = useCallback(
(d1: Date, d2: Date) => {
@ -1824,7 +1827,7 @@ function DBSearchPage() {
denoiseResults={denoiseResults}
collapseAllRows={collapseAllRows}
onSortingChange={onSortingChange}
initialSortBy={orderByConfig ? [orderByConfig] : []}
initialSortBy={initialSortBy}
/>
)}
</>

View file

@ -74,6 +74,17 @@ export default function DBSqlRowTableWithSideBar({
setRowId(null);
setRowSource(null);
}, [setRowId, setRowSource]);
const renderRowDetails = useCallback(
(r: { [key: string]: unknown }) => {
if (!sourceData) {
return <div className="p-3 text-muted">Loading...</div>;
}
return (
<RowOverviewPanelWrapper source={sourceData} rowId={r.id as string} />
);
},
[sourceData],
);
return (
<RowSidePanelContext.Provider value={context ?? {}}>
@ -97,17 +108,7 @@ export default function DBSqlRowTableWithSideBar({
onSortingChange={onSortingChange}
denoiseResults={denoiseResults}
initialSortBy={initialSortBy}
renderRowDetails={r => {
if (!sourceData) {
return <div className="p-3 text-muted">Loading...</div>;
}
return (
<RowOverviewPanelWrapper
source={sourceData}
rowId={r.id as string}
/>
);
}}
renderRowDetails={renderRowDetails}
onScroll={onScroll}
onError={onError}
onExpandedRowsChange={onExpandedRowsChange}