React-native FlatList component

As we know ListView component is deprecated so the best alternative is to use the React-native FlatList component it supports both vertical and horizontal dimension view, also support both Android and IOS device, it support Header and Footer support also we cannot use other libraries for pull to refresh it support pull to refresh, scroll loading, scroll to index, let’s take example

This is the basic syntax of FlatList:

This will display Tom and Jerry values of key name

To explain this in detail, we need to start with fetch call, to display data in FlatList

Fetch call

Create one method to call fetch API call and call this method componentDidMount() method of react-native this will call at app first-time start

Now our response JSON is as follows

To display these JSON data use FlatList as follows

before that, I suggest you install image loader library component by using the following command in the command line

After this, response data had successfully parse and saved this response in the state then use that list from the response object in FlatList component now we will be going to handle on click to do this we have to use the react-native TouchableOpacity onPress method its very simple create another method GetListItem and call this method as follows

activeOpacity props handle onPress opacity animation

let’s see whole js file code so that we can understand clearly

 

React-native FlatList component
React-native FlatList component

Thank you 🙂 enjoy coding…

4 Replies to “React-native FlatList component”

  1. Hi, can you show a demo with an API using POST and an authorization token? I used your boilerplate code but if I modify the API request to a POST call with authorization headers, it fails.

Leave a Reply

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