Skip to content

Commit 06685f5

Browse files
committed
list pagination with tag fix
1 parent d0e0d6d commit 06685f5

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/components/ListPagination.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ const mapDispatchToProps = dispatch => ({
77
dispatch({ type: 'SET_PAGE', page, payload })
88
});
99

10+
const mapStateToProps = state => ({
11+
tag: state.articleList.tag
12+
})
13+
1014
const ListPagination = props => {
1115
if (props.articlesCount <= 10) {
1216
return null;
@@ -17,7 +21,13 @@ const ListPagination = props => {
1721
range.push(i);
1822
}
1923

20-
const setPage = page => props.onSetPage(page, agent.Articles.all(page));
24+
const setPage = page => {
25+
if(props.tag) {
26+
props.onSetPage(page, agent.Articles.byTag(props.tag, page))
27+
}else {
28+
props.onSetPage(page, agent.Articles.all(page))
29+
}
30+
};
2131

2232
return (
2333
<nav>
@@ -48,4 +58,4 @@ const ListPagination = props => {
4858
);
4959
};
5060

51-
export default connect(() => ({}), mapDispatchToProps)(ListPagination);
61+
export default connect(mapStateToProps, mapDispatchToProps)(ListPagination);

0 commit comments

Comments
 (0)