React Native FlatList's scrollToEnd() does not work

react native flatlist onpress
react-native flatlist scrolltoindex
react native flatlist pull to refresh
react native flatlist infinite scroll
react native flatlist space between items
react native flatlist horizontal scroll
react native flatlist pagination
react native flatlist grid

I want to make a floating action button to scroll my FlatList to bottom automatically. My FlatList component described as below:

  ref={(ref) => { this.flatListRef = ref; }}
  contentContainerStyle={this.state.barangFiltered.length === 0 && { paddingTop: 10, justifyContent: 'center', alignItems: 'center' }}
  keyExtractor={(item, index) => `barang-${index}`}
  renderItem={({ item, index }) => <Barang
    duplicateBarang={(item) => this._duplicateBarang(item)}
    deleteBarang={(item) => this._deleteBarang(item)}
  ListEmptyComponent={<Text style={{ fontSize: 16, fontWeight: '400' }}>List is empty</Text>}
  getItemLayout={(data, index) => { return {length: 200, index, offset: 200 * index} }}

And the button component:

  onPress={() => this.flatListRef.scrollToEnd()}
  <Ionicons name="ios-add" size={32} color="#0035C9" />

But, whenever I press the button, it does nothing without produce any error returned. What's going wrong here?

For those who are still looking for a solution, scrollToEnd() is not working because it is triggered before the change is made to the FlatList. Since it inherits from ScrollView the best way here is to call scrollToEnd() in onContentSizeChange like so :

<FlatList ref = "flatList" onContentSizeChange={()=> this.refs.flatList.scrollToEnd()} />

Without setting this prop, FlatList would not know it needs to re-render any items​ is the newest place to search, delivering top results from across the web. Content updated daily for react native development.

A small refine in your code might help.

Class Parent extends React.Component {
    render() {
                <Flatlist />                 // Your flatlist
                <TouchableOpacity />         // Your FAB 

Sometimes your view get overlapped by another view so you cannot perform clicking action. Also give proper positioning as per your design and zIndex to the FAB(floating action button)

What is the FlatList component? 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  Compare Results. Find Find react native developers at

It was solved by removing my ScrollView wrapper of the FlatList component. So, both FLatList and FAB components are in the same parent.

Hey gang, in this React Native tutorial we'll take a look at another way to output lists of data Duration: 7:27 Posted: Dec 2, 2019 Search Find react native developers on Wheather. See yourself. Find react native developers

An introduction to using the FlatList component in React Native Source Code: Duration: 13:57 Posted: Apr 18, 2017 Search For React Native Development that are Great for You!

FlatList s are used for large quantities of scrollable content. They expose the underlying ScrollView , but add performance improvements: only rendering the  By passing extraData= {selected} to FlatList we make sure FlatList itself will re-render when the state changes. Without keyExtractor tells the list to use the id s for the react keys instead of the default key property.

There is no specific component like it is in react-native to do this kind of stuff, so I usually just use map() to achieve this kind of things. But if it is  <FlatList data={[{key: 'a'}, {key: 'b'}]} renderItem={({item}) => <Text>{item.key}</Text>} /> More complex example demonstrating PureComponent usage for perf optimization and avoiding bugs. By binding the onPressItem handler, the props will remain === and PureComponent will prevent wasteful re-renders unless the actual id , selected , or title

  • To help make this answer more useful, could you share relevant parts here instead of just a link? Link only answers aren't very helpful.
  • I just wanted to avoid repeating the same answer but to let it be more useful as you requested this is my solution: <FlatList ref = "flatList" onContentSizeChange={()=> this.refs.flatList.scrollToEnd()} />
  • You basically need to call scrollToEnd()in onContentSizeChange which is a ScrollView function inherited by Flatist and triggered when the data changes.
  • My whole screen structure looks like this: @kosalram-rama-krishnan
  • I tested with alert action to onPress() and it works. It seems not the clicking action problem.
  • Hey @JustinusHermawan you are wrapping a flatlist inside a scroll view which I think unnecessary. Also I'm insisting the same thing again. Your Flatlist and Button need to be siblings of particular parent. <ScrollView> <Flatlist /> <TouchableOpacity /> </ScrollView>
  • Yes, you're right, I just solved it by removing the unnecessary ScrollView. So, they are now siblings.