mirror of
https://github.com/gosticks/react-table.git
synced 2026-07-01 01:50:02 +00:00
Better warnings and more column accessor freedom
This commit is contained in:
27
lib/index.js
27
lib/index.js
File diff suppressed because one or more lines are too long
2
react-table.js
vendored
2
react-table.js
vendored
File diff suppressed because one or more lines are too long
13
src/index.js
13
src/index.js
@@ -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