Quantcast
Channel: Active questions tagged react-native+android - Stack Overflow
Viewing all articles
Browse latest Browse all 29452

react-native Horizontal FlatList - scrollToEnd() makes whole content to move right side of the view on content changed

$
0
0

I am trying to make a breadcrumb for folder traversal. I built a breadcrumb component by horizontal flatlist, and I was using scrollToEnd() method to scroll to end when new item added into the list. I achieved until this by the following code:

<FlatList
        keyExtractor={(item, index) => item + '' + index}
        contentContainerStyle={{
          backgroundColor
        }}
        style={{}}
        bounces={false}
        data={list.slice()}
        horizontal={true}
        onContentSizeChange={() => {
          (listRef.current as any).scrollToEnd({ animated: true });
        }}
        showsHorizontalScrollIndicator={false}
        renderItem={renderBreadCrumb}
        ItemSeparatorComponent={renderItemSeparator}
        ref={listRef}
      />

But I got stuck into another problem. When I am clicking the breadcrumb item decreasingly, it moves the list towards the right of the view. It occurs in Android only, iOS works fine.

I tried, scrollToOffset() for making the list in the correct position. but it doesn't work.


Viewing all articles
Browse latest Browse all 29452

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>