React Native Swipe Down Pull to Refresh ListView Using RefreshControl iOS Android Example Tutorial

RefreshControl control component of react native is used with refreshControl={} prop of ListView, This component will allow us to add Swipe Down Pull to again update JSON data functionality. RefreshControl has its own progress loading indicator which shows automatically when application use swipe down his finger on mobile phone screen and after releasing the finger it will start showing progress loading indicator and in the back start the web call again to parse JSON data into ListView. So in this tutorial we would going to implement Swipe Down Pull to Refresh ListView Using RefreshControl iOS Android React Native App Example Tutorial on JSON Parsing ListView.

Contents in this project Swipe Down Pull to Refresh ListView Using RefreshControl iOS Android React Native App Example Tutorial:

1. We are using our own custom JSON from another tutorial of ours, So if you want to know, how to make your own JSON using PHP MySQL database then read our this tutorial.

Screenshot of JSON used in current tutorial:

2. Import StyleSheet, ActivityIndicator, ListView, Text, View, Alert and RefreshControl component in your project.

3. Create constructor() in your project and make 2 State named as isLoading and refreshingisLoading is used to show and hide the Activity indicator while app loads first time and the refreshing state is used with RefreshControl .

4. Create a function named as GetItem(), This function would show us the current selected item of ListView in alert dialog message.

5. Create a function named as webCall(), This function is our top priority function and used to parse JSON from URL and store in dataSource. We are using the fetch() method to parse JSON.

6. Create a function named as ListViewItemSeparator(), This function would display a horizontal line between each ListView item.

7. Create another function named as onRefresh(), We would use this function to call the above webCall() function. We will call this function form RefreshControl component. Inside this function we would firstly delete all the current items of ListView and make the ListView empty and using the web call again fill the data.

8. Create a IF condition to show the activity indicator on first time app loading time in render’s block.

9. Create ListView component in render’s return block with RefreshControl component.

10. Creating Style.

11. Complete source code for App.js File :

Screenshots:

Swipe Down Pull to Refresh ListView Using RefreshControl

2 Comments

  1. is Select List is available in React Native?? any example

Leave a Reply

Your email address will not be published. Required fields are marked *