Skip to content

Bugfix/issue 1011 change error #1013

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ The component accepts the following props:
|:--:|:-----|:-----|
|**`title`**|array|Title used to caption table
|**`columns`**|array|Columns used to describe table. Must be either an array of simple strings or objects describing a column
|**`data`**|array|Data used to describe table. Must be an array containing objects. (Arrays containing just strings or numbers also supported)
|**`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]])
|**`options`**|object|Options used to describe table

#### Options:
Expand Down
6 changes: 3 additions & 3 deletions src/MUIDataTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -463,14 +463,14 @@ class MUIDataTable extends React.Component {
})
: data.map(row => columns.map(col => leaf(row, col.name)));

// We need to determine if object data exists in the transformed structure, as this is currently not allowed
// 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
const hasInvalidData =
transformedData.filter(
data => data.filter(d => typeof d === 'object' && d !== null && !Array.isArray(d)).length > 0,
).length > 0;
if (hasInvalidData)
throw Error(
`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")`,
console.error(
'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.',
);

return transformedData;
Expand Down