Skip to content

Commit

Permalink
Merge pull request #55 from sematext/table_props
Browse files Browse the repository at this point in the history
Add table level props to component props. fixes #54
  • Loading branch information
amir-hadzic authored May 15, 2017
2 parents e76c734 + 82761e2 commit cdf3813
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/TableRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ const propTypes = {
CheckboxComponent: PropTypes.func,
};

const resolveProps = (row, componentProps) => {
const resolveProps = (row, componentProps, tableProps) => {
if (!componentProps) {
return {};
} else if (_.isFunction(componentProps)) {
return componentProps(row);
return componentProps(row, tableProps);
} else if (_.isObject(componentProps)) {
return componentProps;
}
Expand All @@ -31,6 +31,7 @@ class TableRow extends Component {
headers,
columns,
CheckboxComponent,
...otherProps,
} = this.props;
const select = headers.select;
const visibleColumns = columns.filter((c) => !c.hidden);
Expand All @@ -57,7 +58,7 @@ class TableRow extends Component {
<col.Component
row={row}
key={col.key}
{...resolveProps(row, col.componentProps)}
{...resolveProps(row, col.componentProps, otherProps)}
>
{_.get(row, col.key)}
</col.Component> : _.get(row, col.key)
Expand Down

0 comments on commit cdf3813

Please sign in to comment.