address review: drop ineffective props useMemo with restProps spread

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Evan Rusackas
2026-04-23 08:12:23 -07:00
parent e3eae59568
commit 54faf84527

View File

@@ -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<Record<string, boolean>>(
{},
);
@@ -347,32 +352,6 @@ export function TableRenderer({
const sortCacheRef = useRef(new Map<string, string[][]>());
// Memoize props object to maintain referential stability
const props = useMemo<TableRendererProps>(
() => ({
cols,
rows,
aggregatorName,
tableOptions,
subtotalOptions,
namesMapping: namesMappingProp,
onContextMenu,
allowRenderHtml,
...restProps,
}),
[
cols,
rows,
aggregatorName,
tableOptions,
subtotalOptions,
namesMappingProp,
onContextMenu,
allowRenderHtml,
restProps,
],
);
const clickHandler = useCallback(
(
pivotData: InstanceType<typeof PivotData>,