Ivan - Frontend - Clean code tweak [skip ci]

This commit is contained in:
ivan 2016-09-20 21:19:28 -03:00
parent 36a8e77d8b
commit cb3c54ebca
1 changed files with 4 additions and 7 deletions

View File

@ -55,14 +55,11 @@ class Table extends React.Component {
renderRow(row, index) { renderRow(row, index) {
const headersKeys = this.props.headers.map(header => header.key); const headersKeys = this.props.headers.map(header => header.key);
let renderCurrentRow = true; const minIndex = this.props.pageSize * (this.state.page - 1);
const maxIndex = this.props.pageSize * this.state.page;
const shouldRenderRow = !this.props.pageSize || (index >= minIndex && index < maxIndex);
if (this.props.pageSize && (index >= this.props.pageSize * this.state.page || index < this.props.pageSize * (this.state.page - 1))) { return (shouldRenderRow) ? (
renderCurrentRow = false;
}
return (renderCurrentRow) ? (
<tr className={this.getRowClass(row)} key={index}> <tr className={this.getRowClass(row)} key={index}>
{headersKeys.map(this.renderCell.bind(this, row))} {headersKeys.map(this.renderCell.bind(this, row))}
</tr> </tr>