FlatList in React Native

Updated 6 March 2021

Save

In this blog, I am discussing the FlatList. Basically, FlatList is a react-native Component and use to load the list of data. It’s an easy way to make an efficient scrolling list of data. Not only is it efficient but it’s got an incredibly simple API to work with. If you’ve used or are familiar with the ListView component it’s very similar, just better in (almost) every way. Now ListView is deprecated on react-native.

FlatList has two major props to render the list of data.  such as renderItem and data. renderItem is used for load your each Item View and data your list data set.

The feature of FlatList-

Dynamically changing ViewType-  

FlatList uses key props to change View Type of its items such List to Grid.  Also, one important thing that we need to change the no. of columns dynamically for Grid Type.

 

In Above Code snipped  I have use List View and Grid View display of FlatList items. In Grid View use 2 columns and list View use 1 column. “this.state.isGrid” is changing according to the type of view after clicking the button.   ListEmptyComponent props use for displaying my Empty component what List data is empty. onEndReached props use for pagination of list data and load second-page data when the user reached on the last item after scrolling.

View Of Layout – 

https://mobikul.com/wp-content/uploads/2019/02/Screenshot_20190219-095658_Mobikul-WooCommerce-Marketplace.jpg
https://mobikul.com/wp-content/uploads/2019/02/Screenshot_20190219-095646_Mobikul-WooCommerce-Marketplace.jpg

 

Issues with FlatList- If  I am using FlatList in my App I have faced one issue on Scrolling,

References: 

https://facebook.github.io/react-native/docs/flatlist 

author
. . .

Leave a Comment

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


Be the first to comment.

Start a Project


    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home