Javatpoint Logo
Javatpoint Logo

React Native SectionList

The React Native SectionList component is a list view component which sets the list of data into broken logical section. The broken data can be implemented using its section header prop renderSectionHeader.

To implement the SectionList component, we need to import SectionList from 'react-native' library.

Props of SectionList

sections renderItem initialNumToRender keyExtractor
renderSectionHeader renderSectionFooter onRefresh inverted
extraData onEndReached keyExtractor legacyImplementation
onViewableItemsChanged refreshing removeClippedSubviews ListHeaderComponent
SectionSeparatorComponent stickySectionHeadersEnabled onEndReachedThreshold ListEmptyComponent

React Native SectionList Example

In this example, we create a SectionList with title and data. The sections prop is used to create the list of title and data values. The renderSectionHeader displays the header section of the list view.

Output:

React Native SectionList

Adding Separator in SectionList

ItemSeparatorComponent prop adds the Separator between the lists of data. Using this prop, call a renderSeparatormethod in which we add a View component as separator.

Performing action on SectionList items

To perform an action on clicking (pressing) the list item, we use a onPress prop. The onPress prop and handle the event in another method getListViewItem.

Output:

React Native SectionList React Native SectionList





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA