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';
2
2
import Pagination from 'rc-pagination' ;
3
3
import '../../assets/index.less' ;
4
4
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 {
425
425
} ,
426
426
{ } ,
427
427
) ;
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
+ ) ;
428
437
429
438
if ( simple ) {
430
439
if ( goButton ) {
@@ -467,6 +476,7 @@ class Pagination extends React.Component {
467
476
ref = { this . savePaginationNode }
468
477
{ ...dataOrAriaAttributeProps }
469
478
>
479
+ { totalText }
470
480
< li
471
481
title = { showTitle ? locale . prev_page : null }
472
482
onClick = { this . prev }
@@ -661,19 +671,7 @@ class Pagination extends React.Component {
661
671
pagerList . push ( lastPager ) ;
662
672
}
663
673
}
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
+
677
675
const prevDisabled = ! this . hasPrev ( ) || ! allPages ;
678
676
const nextDisabled = ! this . hasNext ( ) || ! allPages ;
679
677
return (
You can’t perform that action at this time.
0 commit comments