Skip to content

Commit f989e8d

Browse files
committed
fix: address various react warnings
Signed-off-by: Mike Murray <[email protected]>
1 parent 7397342 commit f989e8d

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

package/src/components/DataTable/DataTable.js

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -163,13 +163,14 @@ const DataTable = React.forwardRef(function DataTable(props, ref) {
163163
if (activeFilterCount > maxFilterButtons) {
164164
// If we have more filters, then generate the components
165165
// for the filter drawer
166-
filterDrawerComponents = activeFilters.map((column) => (
167-
React.cloneElement(column.render("Filter"), {
166+
filterDrawerComponents = activeFilters.map((column, index) => (
167+
column.render("Filter", {
168+
container: "card",
169+
key: index,
168170
labels: {
169171
clear: labels.clearFilter,
170172
clearAll: labels.clearAllFilters
171-
},
172-
container: "card"
173+
}
173174
})
174175
));
175176

@@ -189,15 +190,17 @@ const DataTable = React.forwardRef(function DataTable(props, ref) {
189190
className={clsx({
190191
[classes.tableRowOdd]: ((index + 1) % 2 !== 0)
191192
})}
193+
key={`loading-${index}`}
192194
>
193-
{flatColumns.map((column) => {
195+
{flatColumns.map((column, cellIndex) => {
194196
if (column.show === false) return null;
195197

196198
return (
197199
<TableCell
198200
classes={{
199201
root: classes.tableCell
200202
}}
203+
key={`cell-${cellIndex}`}
201204
padding={column.id === "selection" ? "checkbox" : undefined}
202205
>
203206
{column.id === "selection" ? (
@@ -226,15 +229,17 @@ const DataTable = React.forwardRef(function DataTable(props, ref) {
226229
className={clsx({
227230
[classes.tableRowOdd]: ((index + 1) % 2 !== 0)
228231
})}
232+
key={`empty-${index}`}
229233
>
230-
{flatColumns.map((column) => {
234+
{flatColumns.map((column, cellIndex) => {
231235
if (column.show === false) return null;
232236

233237
return (
234238
<TableCell
235239
classes={{
236240
root: classes.tableCell
237241
}}
242+
key={`cell-${cellIndex}`}
238243
padding={column.id === "selection" ? "checkbox" : undefined}
239244
>
240245
{"\u00A0"}
@@ -270,8 +275,9 @@ const DataTable = React.forwardRef(function DataTable(props, ref) {
270275
<ButtonGroup>
271276
{activeFilters
272277
.slice(0, maxFilterButtons)
273-
.map((column) => (
274-
React.cloneElement(column.render("Filter"), {
278+
.map((column, index) => (
279+
column.render("Filter", {
280+
key: index,
275281
labels: {
276282
clear: labels.clearFilter,
277283
clearAll: labels.clearAllFilters
@@ -465,7 +471,7 @@ DataTable.propTypes = {
465471
* Props applied to the built-in action menu. See ActionMenu component for available props.
466472
*/
467473
actionMenuProps: PropTypes.shape({
468-
options: {
474+
options: PropTypes.arrayOf(PropTypes.shape({
469475
/**
470476
* Change the cancel button label in the confirm dialog
471477
*/
@@ -498,7 +504,7 @@ DataTable.propTypes = {
498504
* If supplied, this function will be called in addition to onSelect
499505
*/
500506
onClick: PropTypes.func
501-
}
507+
}))
502508
}),
503509
/**
504510
* Can go to next page
@@ -654,9 +660,9 @@ DataTable.propTypes = {
654660
*/
655661
shouldShowAdditionalFilters: PropTypes.bool,
656662
/**
657-
* Table state [state, updater]
663+
* Table state
658664
*/
659-
state: PropTypes.array
665+
state: PropTypes.object
660666
};
661667

662668
DataTable.defaultProps = {

0 commit comments

Comments
 (0)