File tree Expand file tree Collapse file tree 2 files changed +28
-7
lines changed Expand file tree Collapse file tree 2 files changed +28
-7
lines changed Original file line number Diff line number Diff line change @@ -76,7 +76,7 @@ const BlogList = ({ isAdmin }) => {
76
76
return (
77
77
< div >
78
78
{ renderBlogList ( ) }
79
- < Pagination />
79
+ < Pagination currentPage = { 3 } numberOfPages = { 3 } />
80
80
</ div >
81
81
)
82
82
} ;
Original file line number Diff line number Diff line change 1
- const Pagination = ( ) => {
1
+ import propTypes from "prop-types" ;
2
+
3
+ const Pagination = ( { currentPage, numberOfPages } ) => {
2
4
return (
3
5
< nav aria-label = "Page navigation example" >
4
6
< ul className = "pagination justify-content-center" >
5
7
< li className = "page-item disabled" >
6
- < a className = "page-link" href = "#" tabindex = "-1" aria-disabled = "true" > Previous</ a >
8
+ < a className = "page-link" href = "#" >
9
+ Previous
10
+ </ a >
7
11
</ li >
8
- < li className = "page-item" > < a className = "page-link" href = "#" > 1</ a > </ li >
9
- < li className = "page-item" > < a className = "page-link" href = "#" > 2</ a > </ li >
10
- < li className = "page-item" > < a className = "page-link" href = "#" > 3</ a > </ li >
12
+ { Array ( numberOfPages ) . fill ( 1 ) . map ( ( value , index ) => value + index )
13
+ . map ( ( pageNumber ) => {
14
+ return < li
15
+ key = { pageNumber }
16
+ className = { `page-item ${ currentPage === pageNumber ? 'active' : '' } ` }
17
+ >
18
+ < a className = "page-link" href = "#" > { pageNumber } </ a >
19
+ </ li >
20
+ } ) }
11
21
< li className = "page-item" >
12
- < a className = "page-link" href = "#" > Next</ a >
22
+ < a className = "page-link" href = "#" >
23
+ Next
24
+ </ a >
13
25
</ li >
14
26
</ ul >
15
27
</ nav >
16
28
)
17
29
}
18
30
31
+ Pagination . propTypes = {
32
+ currentPage : propTypes . number ,
33
+ numberOfPages : propTypes . number
34
+ }
35
+
36
+ Pagination . defaultProps = {
37
+ currentPage : 1
38
+ }
39
+
19
40
export default Pagination ;
You can’t perform that action at this time.
0 commit comments