Skip to content

Commit ce9981d

Browse files
gabrielliwerantlalong13
authored andcommitted
Bugfix/issue 1011 change error (gregnb#1013)
* Change error to console error for patch release * Update documentation for clarity around supported data types * Prettify files
1 parent 7285828 commit ce9981d

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ The component accepts the following props:
126126
|:--:|:-----|:-----|
127127
|**`title`**|array|Title used to caption table
128128
|**`columns`**|array|Columns used to describe table. Must be either an array of simple strings or objects describing a column
129-
|**`data`**|array|Data used to describe table. Must be an array containing objects. (Arrays containing just strings or numbers also supported)
129+
|**`data`**|array|Data used to describe table. Must be either an array containing objects of key/value pairs with values that are strings or numbers, or arrays of strings or numbers (Ex: data: [{"Name": "Joe", "Job Title": "Plumber", "Age": 30}, {"Name": "Jane", "Job Title": "Electrician", "Age": 45}] or data: [["Joe", "Plumber", 30], ["Jane", "Electrician", 45]])
130130
|**`options`**|object|Options used to describe table
131131

132132
#### Options:

src/MUIDataTable.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -463,14 +463,14 @@ class MUIDataTable extends React.Component {
463463
})
464464
: data.map(row => columns.map(col => leaf(row, col.name)));
465465

466-
// We need to determine if object data exists in the transformed structure, as this is currently not allowed
466+
// We need to determine if object data exists in the transformed structure, as this is currently not allowed and will cause errors if not handled by a custom renderer
467467
const hasInvalidData =
468468
transformedData.filter(
469469
data => data.filter(d => typeof d === 'object' && d !== null && !Array.isArray(d)).length > 0,
470470
).length > 0;
471471
if (hasInvalidData)
472-
throw Error(
473-
`Cannot accept objects for cell data. Cells need to contain strings | numbers. It\'s possible this error is the result of a missing dot in the column name field (e.g. name: "company" instead of name: "company.id")`,
472+
console.error(
473+
'Deprecated: Passing objects in as data is not supported, and will be prevented in a future release. Consider using ids in your data and linking it to external objects if you want to access object data from custom render functions.',
474474
);
475475

476476
return transformedData;

0 commit comments

Comments
 (0)