React Native FlatList Pagination to Load More Data dynamically – Infinite List

Here is an example of React Native FlatList Pagination to Load More Data dynamically – Infinite List. In this example, we will make a FlatList in which we will load the data in the form of pagination on a Click of a button.

For those who don’t know what is pagination?

Let’s take a case where you can simply imagine what if Facebook loads all the Facebook posts from the Facebook database on your Facebook wall? Doesn’t it sound nasty? It will take hundreds of hours even more than that so what is the best way to load the data?  Simply paging. When you open the Facebook they just show you 10-20 post and while you scroll the Facebook they load next 10-20 posts in background. That is what the paging is.

In our example,

  1. We are loading the first 10 posts from the web API call in componentDidMount.
  2. We have added load more button on the footer of the list.
  3. While clicking on the Load More Button we call the Web API again to get the next 10 posts.

We are using a variable offset to manage the index on upcoming Data. We will increase the offset by 1 after the successful call of the web API so that when we call the web API next time we will get the next dataset. So let’s get started with the example.

To Make a React Native App

Getting started with React Native will help you to know more about the way you can make a React Native project. We are going to use react-native init to make our React Native App. Assuming that you have node installed, you can use npm to install the react-native-cli command line utility. Open the terminal and go to the workspace and run

npm install -g react-native-cli

Run the following commands to create a new React Native project

react-native init ProjectName

If you want to start a new project with a specific React Native version, you can use the --version argument:

react-native init ProjectName --version X.XX.X
react-native init ProjectName --version react-native@next

This will make a project structure with an index file named App.js in your project directory.

Open App.js in any code editor and the Replace the code with the following code.


To Run the React Native App

Open the terminal again and jump into your project using.
cd ProjectName
To run the project on an Android Virtual Device or on real debugging device
react-native run-android
or on the iOS Simulator by running
react-native run-ios (macOS only).

After Clicking on Load More It will load the data with the loader in Button

That was the React Native FlatList with Pagination to Load More Data dynamically. If you have any doubt or you want to share something about the topic you can comment below or contact us here. There will be more posts coming soon. Stay tuned!

Hope you liked it. 🙂

15 thoughts on “React Native FlatList Pagination to Load More Data dynamically – Infinite List”

  1. I am trying to do pagination with ActivityIndicator in react native but this functionality is not working properly.
    So please can you tell me about this.
    Thank You

  2. first this: this.offset = 0;
    second this: this.offset + 10;
    three this: this.offset + 10;

    10 is quantity itens per page.

    Very good, clean..

  3. But this will increase the memory that your application is using on every fetch. The state will becoming larger and larger. Finally, the application will run out of memory. Am I wrong?

  4. If we have fetched all the data after specific offset then how to remove the load more icon then? As all the data has been fetched then the load more button would not be necessary there.

    • There can be many logics for that but what I usually do is while calling web service I have an idea how much data can come in a single call, for example, service will return 50 data sets in a single call so I make a logic to count the response and if it is 50 then I make the button state visible and if I get less no of data sets then I hide the button as this is the last set of the data. If you want to make the per call number dynamic you can ask your backend developer to send the max number of data set which can come in a single call.

  5. Hello, great post.

    I have a question. How to do this without the button, just when you come to the end of the list, it will load the next offset?

    Thanks for the reply,



Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.