FlatList vs ScrollView in React Native

In this article we talk about one of the most important topics is flat list and scroll view which comes, under-react native. Firstly we discuss is flat lists all we know is that a flat list is used for rendering so much data in our component. With the help of a flat list, similar data can easily show our mobile application. In flat list have different props but there are two required props in the flat list are- data and render items. And if we use a flat list so we import at the top of our react component then we can use it easily. If you have a large array of data so flat list can be easily deal with large data and only render items that can be visible on the screen.

FlatList Syntax:-

Data props can be starting from an array of numbers they can fill with JSON objects and they are fetched through our rest API.

Render props basically is a function that accepts every item & object from the source array(data props)and renders the data into our component.

How to implement a flat list in our code:-

import React  from

Scrollview:-Scrollview component is worked as a flat list component also. But some features are different from the flat list. In scroll, the view has limited props which can be used in our component. In scroll, the view provides the functionality for scrolling our component in both directions- vertical and horizontal but they generally work vertically by default. They also provide the refresh functionality for rendering our component.

Props of scrollview are horizontal, refreshControl,horizontal,onScroll,scrollEnabled,contentContainerStyle,snapToStart etc so many props have.

 Example of scroll view:-

 

Leave a Reply