Answer the question
In order to leave comments, you need to log in
Why is the redux store full of duplicates?
Good afternoon! I was faced with the task of implementing pagination, for this the following steps were taken:
The first step was to create a new function in the reducer:
case SET_CURRENT_PAGE: {
return {
...state,
currentPage: action.payload
}
}
useEffect(() => {
axios.get(`/post/${props.numbersPage.currentPage}`)
.then(res => {
res.data.forEach(item => {
props.addPost(item.id);
});
}, [props.numbersPage.currentPage]);
<div className="page">
{pages.map((page, index) => <span
onClick={() => dispatch(setCurrentPageAC(page))}
key={index}>{page}
</span>)}
</div>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question