File tree Expand file tree Collapse file tree 2 files changed +10
-18
lines changed Expand file tree Collapse file tree 2 files changed +10
-18
lines changed Original file line number Diff line number Diff line change 56
56
"createdAt" : 1647211385146 ,
57
57
"id" : 9
58
58
},
59
- {
60
- "title" : " test" ,
61
- "body" : " test" ,
62
- "publish" : false ,
63
- "createdAt" : 1647211425309 ,
64
- "id" : 10
65
- },
66
- {
67
- "title" : " test1" ,
68
- "body" : " test1" ,
69
- "publish" : false ,
70
- "createdAt" : 1647211538719 ,
71
- "id" : 11
72
- },
73
59
{
74
60
"title" : " test2" ,
75
61
"body" : " test2" ,
Original file line number Diff line number Diff line change @@ -26,6 +26,8 @@ const BlogList = ({ isAdmin }) => {
26
26
27
27
const onClickPageButton = ( page ) => {
28
28
history . push ( `${ location . pathname } ?page=${ page } ` )
29
+ setCurrentPage ( page ) ;
30
+ getPosts ( page ) ;
29
31
}
30
32
31
33
const getPosts = useCallback ( ( page = 1 ) => {
@@ -52,8 +54,8 @@ const BlogList = ({ isAdmin }) => {
52
54
53
55
useEffect ( ( ) => {
54
56
setCurrentPage ( parseInt ( pageParam ) || 1 ) ;
55
- getPosts ( parseInt ( pageParam ) || 1 ) ;
56
- } , [ pageParam , getPosts ] ) ;
57
+ getPosts ( parseInt ( pageParam ) || 1 )
58
+ } , [ ] ) ;
57
59
58
60
const deleteBlog = ( e , id ) => {
59
61
e . stopPropagation ( ) ;
@@ -90,8 +92,12 @@ const BlogList = ({ isAdmin }) => {
90
92
} )
91
93
}
92
94
93
- const onSearch = ( ) => {
94
- getPosts ( 1 ) ;
95
+ const onSearch = ( e ) => {
96
+ if ( e . key === 'Enter' ) {
97
+ history . push ( `${ location . pathname } ?page=1` )
98
+ setCurrentPage ( 1 ) ;
99
+ getPosts ( 1 ) ;
100
+ }
95
101
}
96
102
97
103
return (
You can’t perform that action at this time.
0 commit comments