Do you think IIT Guwahati certified course can help you in your career?
No
Introduction
There are several times we have seen scrollable items in a Mobile application. Sometimes the list items are very large and dynamic. With the help of React Native, we can easily implement those scrollable lists.
In React Native, there are several ways to build a scrolling list, the most notable of which are the ScrollView and the ListView. Each has advantages and disadvantages. Since v0.43 of React Native, we've had access to two additional list views, the FlatList and the SectionList. We'll look at how to use the FlatList component in-depth.
The FlatList is a React Native component that makes it simple to create a scrolling list of data. It's efficient and also has a straightforward API to deal with. It works effectively with large data lists where the number of items in the list may change over time. FlatList only displays the only elements currently visible on the screen, not the entire list at once. You no longer need to format the data; simply provide it with an array of data and start rendering right away.
In a FlatList, data and renderItem are the two most important props to understand. The first is an array of data used to generate the list, which is commonly an array of objects, and the second is a function that renders a component for each piece in the data array.
To implement the FlatList component, we need to import FlatList from the react-native library.
Some of the handiest features of Flatlist are given below:-
1.) It is entirely Cross-Platform.
2.) It provides the Optional horizontal mode.
3.) It provides Configurable viewability callbacks.
4.) Header support.
5.) Footer support.
6.) Separator support.
7.) ScrollToIndex support.
8.) Multiple column support.
9.) Pull to Refresh is available.
10.) Scroll loading.
React Native Flatlist Example
In this example, we provide hardcoded elements to the data prop. Each element in the data props is rendered as a Text component.
The separator between the list elements is implemented using the FlatList's ItemSeparatorComponent prop. We use the onPress prop to Text to conduct the click event on list elements.
The FlatList is a React Native component that makes it simple to create a scrolling list of data. It's efficient and also has a straightforward API to deal with.
Mention some features of Flatlist?
Some features of Flatlist are Fully Cross-Platformed, Header Support, Footer Support, Separator Support, Multiple Coloum Support, etc.
What are the advantages of Using FlatList?
The main advantage of using the Flatlist component is that it works effectively with large data lists where the number of items in the list may change over time. FlatList only displays the only elements currently visible on the screen, not the entire list at once.