I want to show some news in my React app using Redux.
The problem is that I want to show the news for individual dates and I want to paginate the news.
In my API I print
{
pagination: {
count: 1000,
size: 10,
page: 1,
pages: 100
},
news: [
..
]
}
I know how to make a simple pagination, but I don't know how the API should work if I want to be able to show news for different dates in my app.
Until now (without dates), I have just kept a state news and pagination in my Redux reducer, and then checked if the page number equals the total number of pages to determine whether it should try loading more news.
But now that I potentially have many different dates and I want to keep all the news in the Redux store, I don't know how to structure it.
I can keep my API as it is, since filtering with GET parameter ?date=15-09-2017 will just decrease the number of news in the API result.
But would it still be possible to just keep all the news in an array in a news variable in my reducer or do I have to structure it to be something like
news: {
'15-09-2017': {
news: [...],
pagination: {}
},
...
}
in order to keep track of the pagination for every single date?