-
Notifications
You must be signed in to change notification settings - Fork 2
Pagination #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Pagination #2
Conversation
…e in relation with the pagination
…e in relation with the pagination
… first object if the dataset is not an array. Refactored some methods and variable's names
src/components/TablePagination.js
Outdated
| if (page >= 0 && page < this.props.pageCount) { | ||
| this.props.changeHandler(page); | ||
| } | ||
| this.props.currentPage === 0 ? this.setState({ previousDisabled: true }) : this.setState({ previousDisabled: false }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This whole line could be replace with :
this.setState({ previousDisabled: !!this.props.currentPage });
in fact, the "previousDisabled" property should be replaced by and accessor such as :
isPreviousDisabled() {
return !!this.props.currentPage;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as nextDisabled
src/components/TablePagination.js
Outdated
| this.props.currentPage == this.props.pageCount - 2 ? this.setState({ nextDisabled: true }) : this.setState({ nextDisabled: false }); | ||
| } | ||
|
|
||
| renderPagination() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method should be divided into smaller ones
| @@ -0,0 +1,20 @@ | |||
| import React from 'react'; | |||
|
|
|||
| class TablePaginationPage extends React.Component { | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be a stateless component
src/components/Tabledata.js
Outdated
| export default class Tabledata extends Component { | ||
| constructor(props) { | ||
| super(props); | ||
| this._rowsToDisplay = this.props.rowsToDisplay ? this.props.rowsToDisplay : DEFAULT_ROWS_PER_PAGE; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be an accessor instead
Added pagination system that allows the user to enter a number of row to display on the table. If nothing is specified, the default rows per page is 10.