Skip to content
This repository has been archived by the owner on Jan 15, 2022. It is now read-only.

Commit

Permalink
Revert "prototype solution to custom components"
Browse files Browse the repository at this point in the history
This reverts commit 1fc822d.
  • Loading branch information
glittershark committed Sep 30, 2015
1 parent 1fc822d commit d19826d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 51 deletions.
48 changes: 4 additions & 44 deletions src/reactable/table.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export class Table extends React.Component {
super(props);

this.state = {
parsedCustomComponents: false,
currentPage: 0,
currentSort: {
column: null,
Expand Down Expand Up @@ -54,7 +53,7 @@ export class Table extends React.Component {
}

parseChildData(props) {
let data = [], tfoot, customComponentsCount = 0;
let data = [], tfoot;

// Transform any children back to a data array
if (typeof(props.children) !== 'undefined') {
Expand Down Expand Up @@ -113,26 +112,19 @@ export class Table extends React.Component {
__reactableMeta: true
});
break;
default:
// Don't know if there are other acceptable types
// that should be dismissed
// console.log("Table, got custom component", child.type)
customComponentsCount++;
break;
}
}.bind(this));
}

return { data, tfoot, customComponentsCount };
return { data, tfoot };
}

initialize(props) {
this.data = props.data || [];
let { data, tfoot, customComponentsCount } = this.parseChildData(props);
let { data, tfoot } = this.parseChildData(props);

this.data = this.data.concat(data);
this.tfoot = tfoot;
this.customComponentsCount = customComponentsCount;

this.initializeSorts(props);
}
Expand Down Expand Up @@ -214,26 +206,6 @@ export class Table extends React.Component {
this.sortByCurrentSort();
}

componentDidMount() {
for (var i = 0; i < this.customComponentsCount; i++) {
let child = this.refs['child-'+i],
childData = child.getData(),
childDataToPush = {};
for (var key in childData){
childDataToPush[key] = {
value: childData[key],
__reactableMeta: true
};
}
this.data.push({
data: childDataToPush,
props: filterPropsFrom(child.props),
__reactableMeta: true
});
};
this.setState({parsedCustomComponents: true});
}

componentWillReceiveProps(nextProps) {
this.initialize(nextProps);
this.updateCurrentSort(nextProps.sortBy);
Expand Down Expand Up @@ -325,20 +297,8 @@ export class Table extends React.Component {
this.setState({ currentSort: currentSort });
this.sortByCurrentSort();
}
renderUnparsedDataTable() {
// http://www.mattzabriskie.com/blog/react-referencing-dynamic-children
let index = 0;
let children = React.Children.map(this.props.children, function (child) {
return React.addons.cloneWithProps(child, {ref: 'child-' + (index++) });
});

return <div>{children}</div>;
}
render() {
if (!this.state.parsedCustomComponents && this.customComponentsCount > 0){
return this.renderUnparsedDataTable();
}

render() {
let children = [];
let columns;
let userColumnsSpecified = false;
Expand Down
7 changes: 0 additions & 7 deletions tests/reactable_test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -426,13 +426,6 @@ describe('Reactable', function() {
age: React.PropTypes.number,
position: React.PropTypes.string
},
getData: function(){
return {
Name: this.props.name,
Age: this.props.age,
Position: this.props.position,
}
},
render: function(){
return (
<Reactable.Tr>
Expand Down

0 comments on commit d19826d

Please sign in to comment.