M
M
mr jeery2018-02-08 19:59:37
JavaScript
mr jeery, 2018-02-08 19:59:37

How to make api pagination in react?

Good afternoon.
I'm learning react and faced the following problem:
I have a .json file with api - a huge array of cities.
You need to display 10 cities per page and make pagination.
But doing a single fetch to the entire array and assigning all cities to state is not an option because of the volume, as it seems to me.
You must first load the first 10 elements, after clicking on "load more" - make a request for the next 20 elements and thus replenish the state.
found such an example using google with the phrase "api pagination"
gaearon.github.io/flux-react-router-example/#
But it seems too complicated and confusing to me.
Tell me the recipe or share some article or a link to github that will help to implement the plan.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question