Skip to content

Commit 250618d

Browse files
committed
62
1 parent 2f04d05 commit 250618d

File tree

2 files changed

+10
-18
lines changed

2 files changed

+10
-18
lines changed

db.json

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -56,20 +56,6 @@
5656
"createdAt": 1647211385146,
5757
"id": 9
5858
},
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-
},
7359
{
7460
"title": "test2",
7561
"body": "test2",

src/components/BlogList.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ const BlogList = ({ isAdmin }) => {
2626

2727
const onClickPageButton = (page) => {
2828
history.push(`${location.pathname}?page=${page}`)
29+
setCurrentPage(page);
30+
getPosts(page);
2931
}
3032

3133
const getPosts = useCallback((page = 1) => {
@@ -52,8 +54,8 @@ const BlogList = ({ isAdmin }) => {
5254

5355
useEffect(() => {
5456
setCurrentPage(parseInt(pageParam) || 1);
55-
getPosts(parseInt(pageParam) || 1);
56-
}, [pageParam, getPosts]);
57+
getPosts(parseInt(pageParam) || 1)
58+
}, []);
5759

5860
const deleteBlog = (e, id) => {
5961
e.stopPropagation();
@@ -90,8 +92,12 @@ const BlogList = ({ isAdmin }) => {
9092
})
9193
}
9294

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+
}
95101
}
96102

97103
return (

0 commit comments

Comments
 (0)