address review: move sort cache clear to structural-deps effect

This commit is contained in:
Evan Rusackas
2026-04-23 02:32:30 -07:00
parent 1dde65f901
commit d9b15c3f4c

View File

@@ -754,14 +754,16 @@ export function TableRenderer({
);
// Compute base pivot settings, memoized based on relevant props
const basePivotSettings = useMemo(() => {
// Clear sort cache when props change
sortCacheRef.current.clear();
return getBasePivotSettings();
}, [getBasePivotSettings]);
const basePivotSettings = useMemo(
() => getBasePivotSettings(),
[getBasePivotSettings],
);
// Reset sort state when structural props change
// Reset sort state and cache when structural props change. Scoping this to
// an effect (instead of running inside the memo) prevents the cache from
// being wiped on unrelated state updates like collapse/expand.
useEffect(() => {
sortCacheRef.current.clear();
setSortingOrder([]);
setActiveSortColumn(null);
setSortedRowKeys(null);