Skip to content

Commit da3c19e

Browse files
authored
fix(AnalyticalTable): fix React key warning (#7100)
This warning was introduced in React v18.3. Fixes #7093
1 parent 3976521 commit da3c19e

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

packages/main/src/components/AnalyticalTable/ColumnHeader/ColumnHeaderContainer.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ import { classNames, styleData } from './Resizer.module.css.js';
66
import { ColumnHeader } from './index.js';
77

88
interface ColumnHeaderContainerProps {
9-
headerProps: Record<string, unknown>;
10-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
9+
headerProps: Record<string, any>;
1110
headerGroup: Record<string, any>;
1211
onSort: (e: CustomEvent<{ column: unknown; sortDirection: string }>) => void;
1312
onGroupByChanged: (e: CustomEvent<{ column?: Record<string, unknown>; isGrouped?: boolean }>) => void;
@@ -32,12 +31,14 @@ export const ColumnHeaderContainer = forwardRef<HTMLDivElement, ColumnHeaderCont
3231
uniqueId,
3332
showVerticalEndBorder
3433
} = props;
34+
const { key, ...reactTableHeaderProps } = headerProps;
3535

3636
useStylesheet(styleData, 'Resizer');
3737

3838
return (
3939
<div
40-
{...headerProps}
40+
key={key}
41+
{...reactTableHeaderProps}
4142
style={{ width: `${columnVirtualizer.getTotalSize()}px` }}
4243
ref={ref}
4344
data-component-name="AnalyticalTableHeaderRow"

packages/main/src/components/AnalyticalTable/TableBody/VirtualTableBody.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ export const VirtualTableBody = (props: VirtualTableBodyProps) => {
151151
lastNonEmptyRow.current = row;
152152
}
153153
prepareRow(row);
154-
const rowProps = row.getRowProps({
154+
const { key, ...rowProps } = row.getRowProps({
155155
'aria-rowindex': virtualRow.index + 1,
156156
'data-virtual-row-index': virtualRow.index
157157
});
@@ -190,8 +190,8 @@ export const VirtualTableBody = (props: VirtualTableBodyProps) => {
190190
: rowVirtualizer.measureElement;
191191

192192
return (
193-
// eslint-disable-next-line react/jsx-key
194193
<div
194+
key={key}
195195
{...rowProps}
196196
ref={measureRef}
197197
style={{
@@ -227,7 +227,7 @@ export const VirtualTableBody = (props: VirtualTableBodyProps) => {
227227
if (!cell) {
228228
return null;
229229
}
230-
const cellProps = cell.getCellProps();
230+
const { key, ...cellProps } = cell.getCellProps();
231231
const allCellProps = {
232232
...cellProps,
233233
['data-visible-column-index']: visibleColumnIndex,
@@ -269,8 +269,11 @@ export const VirtualTableBody = (props: VirtualTableBodyProps) => {
269269
}
270270

271271
return (
272-
// eslint-disable-next-line react/jsx-key
273-
<div {...allCellProps} data-selection-cell={cell.column.id === '__ui5wcr__internal_selection_column'}>
272+
<div
273+
key={key}
274+
{...allCellProps}
275+
data-selection-cell={cell.column.id === '__ui5wcr__internal_selection_column'}
276+
>
274277
{popInRowHeight !== internalRowHeight && popInColumn.id === cell.column.id
275278
? cell.render('PopIn', { contentToRender, internalRowHeight })
276279
: cell.render(contentToRender, isNavigatedCell === true ? { isNavigatedCell } : {})}

0 commit comments

Comments
 (0)