Skip to content

Commit 07d2e4c

Browse files
committed
make changeSizePerPage accept a number instead of an event object
1 parent 817eac3 commit 07d2e4c

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/pagination/PaginationList.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,8 @@ class PaginationList extends Component {
4545
}
4646
}
4747

48-
changeSizePerPage = e => {
49-
e.preventDefault();
50-
51-
const selectSize = parseInt(e.currentTarget.getAttribute('data-page'), 10);
48+
changeSizePerPage = pageNum => {
49+
const selectSize = typeof pageNum === 'string' ? parseInt(pageNum, 10) : pageNum;
5250
let { currPage } = this.props;
5351
if (selectSize !== this.props.sizePerPage) {
5452
this.totalPages = Math.ceil(this.props.dataSize / selectSize);
@@ -164,7 +162,10 @@ class PaginationList extends Component {
164162
<a role='menuitem'
165163
tabIndex='-1' href='#'
166164
data-page={ pageNum }
167-
onClick={ this.changeSizePerPage }>{ pageText }</a>
165+
onClick={ e => {
166+
e.preventDefault();
167+
this.changeSizePerPage(pageNum);
168+
} }>{ pageText }</a>
168169
</li>
169170
);
170171
});

0 commit comments

Comments
 (0)