Pagination In React Native- Load More Data Dynamically


The principle of loading a lot of data into chunks is pagination. Consider a situation in which you have to fill a list of the names of 1000 individuals, so if we load all the data at once, loading time and response time would also increase to enhance this, we will enforce the pagination principle. 

Process Flow 

We’re going to use the FlatList definition to populate the data into a list to enforce pagination. The following are two ways of doing this: 

  1. By using ListFooterComponent props. 
  2. By using OnEndReached and onEndReachedThreshold props.

1. ListFooterComponent 

ListFooterComponent is a prop used by flatlist to render any footer component. For Ex: If you want to render a submit button or any information after the list then we will use this prop.

2. OnEndReached and onEndReachedThreshold 

OnEndReached is another prop which accepts a function as value and whatever logic you want to perform, you can perform it. OnEndReachedThreshold will specify how far from the end (in units of visible length of the list) the bottom edge of the list must be from the end of the content to trigger the onEndReached callback. 


In this blog, I am going to use the following scenario:

1. We are loading the first 10 rows from the web API call in useEffect hook.

2. While the user reaches the bottom of the list we call the Web API again to get the next 10 rows.

Note: We are using an open-source API for rendering data.

  1. By Using ListFooter Component

  1. By Using OnEndReached and OnEndReachedThreshold

We have to pass this as a function reference in onEndReached props so that it will get executed. 



Leave a Reply