File tree Expand file tree Collapse file tree 2 files changed +23
-14
lines changed Expand file tree Collapse file tree 2 files changed +23
-14
lines changed Original file line number Diff line number Diff line change @@ -2,4 +2,15 @@ import React from 'react';
22import Pagination from 'rc-pagination' ;
33import '../../assets/index.less' ;
44
5- export default ( ) => < Pagination simple defaultCurrent = { 1 } total = { 50 } /> ;
5+ export default ( ) => (
6+ < >
7+ < Pagination simple defaultCurrent = { 1 } total = { 50 } />
8+ < br />
9+ < Pagination
10+ simple
11+ defaultCurrent = { 1 }
12+ total = { 50 }
13+ showTotal = { ( total ) => `Total ${ total } items` }
14+ />
15+ </ >
16+ ) ;
Original file line number Diff line number Diff line change @@ -425,6 +425,15 @@ class Pagination extends React.Component {
425425 } ,
426426 { } ,
427427 ) ;
428+
429+ const totalText = showTotal && (
430+ < li className = { `${ prefixCls } -total-text` } >
431+ { showTotal ( total , [
432+ total === 0 ? 0 : ( current - 1 ) * pageSize + 1 ,
433+ current * pageSize > total ? total : current * pageSize ,
434+ ] ) }
435+ </ li >
436+ ) ;
428437
429438 if ( simple ) {
430439 if ( goButton ) {
@@ -467,6 +476,7 @@ class Pagination extends React.Component {
467476 ref = { this . savePaginationNode }
468477 { ...dataOrAriaAttributeProps }
469478 >
479+ { totalText }
470480 < li
471481 title = { showTitle ? locale . prev_page : null }
472482 onClick = { this . prev }
@@ -661,19 +671,7 @@ class Pagination extends React.Component {
661671 pagerList . push ( lastPager ) ;
662672 }
663673 }
664-
665- let totalText = null ;
666-
667- if ( showTotal ) {
668- totalText = (
669- < li className = { `${ prefixCls } -total-text` } >
670- { showTotal ( total , [
671- total === 0 ? 0 : ( current - 1 ) * pageSize + 1 ,
672- current * pageSize > total ? total : current * pageSize ,
673- ] ) }
674- </ li >
675- ) ;
676- }
674+
677675 const prevDisabled = ! this . hasPrev ( ) || ! allPages ;
678676 const nextDisabled = ! this . hasNext ( ) || ! allPages ;
679677 return (
You can’t perform that action at this time.
0 commit comments