mirror of
https://github.com/gosticks/react-table.git
synced 2026-10-03 14:26:55 +00:00
Better warnings and more column accessor freedom
This commit is contained in:
+19
-8
File diff suppressed because one or more lines are too long
Vendored
+1
-1
File diff suppressed because one or more lines are too long
+8
-5
@@ -96,17 +96,20 @@ export default React.createClass({
|
||||
}
|
||||
const makeDecoratedColumn = (column) => {
|
||||
const dcol = Object.assign({}, this.props.column, column)
|
||||
|
||||
if (typeof dcol.accessor === 'string') {
|
||||
dcol.id = dcol.id || dcol.accessor
|
||||
const accessorString = dcol.accessor
|
||||
dcol.accessor = row => _.get(row, accessorString)
|
||||
return dcol
|
||||
}
|
||||
if (!dcol.id) {
|
||||
console.warn('No column ID found for column: ', dcol)
|
||||
}
|
||||
if (!dcol.accessor) {
|
||||
console.warn('No column accessor found for column: ', dcol)
|
||||
|
||||
if (dcol.accessor && !dcol.id) {
|
||||
console.warn(dcol)
|
||||
throw new Error('A column id is required if using a non-string accessor for column above.')
|
||||
}
|
||||
|
||||
dcol.accessor = d => undefined
|
||||
return dcol
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user