Skip to content

Commit 427d3cd

Browse files
committed
Fix React warning about spreading key in props
1 parent dc7e752 commit 427d3cd

File tree

3 files changed

+666
-725
lines changed

3 files changed

+666
-725
lines changed

packages/bento-design-system/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,8 @@
190190
"playroom": "0.32.1",
191191
"postcss": "8.4.47",
192192
"prettier": "2.8.8",
193-
"react": "18.2.0",
194-
"react-dom": "18.2.0",
193+
"react": "18.3.1",
194+
"react-dom": "18.3.1",
195195
"storybook": "8.0.8",
196196
"style-loader": "3.3.4",
197197
"ts-loader": "9.4.4",

packages/bento-design-system/src/Table/Table.tsx

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -375,20 +375,24 @@ export function Table<
375375
rowIndex: number,
376376
interactiveRow: boolean
377377
) {
378-
return cells.map((cell, index) => (
379-
<CellContainer
380-
{...cell.getCellProps()}
381-
index={rowIndex}
382-
lastLeftSticky={index === lastStickyColumnIndex}
383-
style={stickyLeftColumnStyle[cell.column.id]}
384-
first={index === 0}
385-
last={(index + 1) % flatColumns.length === 0}
386-
interactiveRow={interactiveRow}
387-
withDividers={withDividers}
388-
>
389-
{cell.render("Cell")}
390-
</CellContainer>
391-
));
378+
return cells.map((cell, index) => {
379+
const { key, ...cellProps } = cell.getCellProps();
380+
return (
381+
<CellContainer
382+
key={key}
383+
{...cellProps}
384+
index={rowIndex}
385+
lastLeftSticky={index === lastStickyColumnIndex}
386+
style={stickyLeftColumnStyle[cell.column.id]}
387+
first={index === 0}
388+
last={(index + 1) % flatColumns.length === 0}
389+
interactiveRow={interactiveRow}
390+
withDividers={withDividers}
391+
>
392+
{cell.render("Cell")}
393+
</CellContainer>
394+
);
395+
});
392396
}
393397

394398
const rowsToRender = virtualizeRows
@@ -581,6 +585,7 @@ function ColumnHeader<D extends Record<string, unknown>>({
581585
) : null;
582586

583587
const hasHeaderContent = column.Header || hint || sortIcon;
588+
const { key: _key, ...headerProps } = column.getHeaderProps(column.getSortByToggleProps());
584589

585590
return (
586591
<Box
@@ -598,7 +603,7 @@ function ColumnHeader<D extends Record<string, unknown>>({
598603
className={[columnHeader({ withDividers, first, lastLeftSticky })]}
599604
background={config.headerBackgroundColor}
600605
color={config.headerForegroundColor}
601-
{...column.getHeaderProps(column.getSortByToggleProps())}
606+
{...headerProps}
602607
textAlign={column.align}
603608
{...config.padding.header}
604609
>

0 commit comments

Comments
 (0)