From 54faf845270b6d712773fb17efc4d56d203e2e3c Mon Sep 17 00:00:00 2001 From: Evan Rusackas Date: Thu, 23 Apr 2026 08:12:23 -0700 Subject: [PATCH] address review: drop ineffective props useMemo with restProps spread Co-Authored-By: Claude Opus 4.7 --- .../src/react-pivottable/TableRenderers.tsx | 53 ++++++------------- 1 file changed, 16 insertions(+), 37 deletions(-) diff --git a/superset-frontend/plugins/plugin-chart-pivot-table/src/react-pivottable/TableRenderers.tsx b/superset-frontend/plugins/plugin-chart-pivot-table/src/react-pivottable/TableRenderers.tsx index 51fd78ea212..d3e58763827 100644 --- a/superset-frontend/plugins/plugin-chart-pivot-table/src/react-pivottable/TableRenderers.tsx +++ b/superset-frontend/plugins/plugin-chart-pivot-table/src/react-pivottable/TableRenderers.tsx @@ -324,17 +324,22 @@ function convertToArray( return result; } -export function TableRenderer({ - cols, - rows, - aggregatorName, - tableOptions = {}, - subtotalOptions, - namesMapping: namesMappingProp, - onContextMenu, - allowRenderHtml, - ...restProps -}: TableRendererProps) { +export function TableRenderer(props: TableRendererProps) { + // Use the original props argument directly rather than spreading/re-memoizing. + // Spreading `...rest` into a memoized object produces a new reference every + // render, which defeats downstream memos and forces `getBasePivotSettings` + // (and a fresh `PivotData`) to recompute on every state update. + const { + cols, + rows, + aggregatorName, + tableOptions = {}, + subtotalOptions, + namesMapping: namesMappingProp, + onContextMenu, + allowRenderHtml, + } = props; + const [collapsedRows, setCollapsedRows] = useState>( {}, ); @@ -347,32 +352,6 @@ export function TableRenderer({ const sortCacheRef = useRef(new Map()); - // Memoize props object to maintain referential stability - const props = useMemo( - () => ({ - cols, - rows, - aggregatorName, - tableOptions, - subtotalOptions, - namesMapping: namesMappingProp, - onContextMenu, - allowRenderHtml, - ...restProps, - }), - [ - cols, - rows, - aggregatorName, - tableOptions, - subtotalOptions, - namesMappingProp, - onContextMenu, - allowRenderHtml, - restProps, - ], - ); - const clickHandler = useCallback( ( pivotData: InstanceType,