Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React Native ListView scrollToEnd it doesn't work

I use the ListView's scrollToEnd, but it doesn't work, but it worked for scrollTo. What should I do to deal with it.

enter image description here

enter image description here

like image 886
Aaron_ls Avatar asked Feb 18 '17 09:02

Aaron_ls


People also ask

How do I use scroll view react native?

Using ScrollViewScrollViews can be configured to allow paging through views using swiping gestures by using the pagingEnabled props. Swiping horizontally between views can also be implemented on Android using the ViewPager component. On iOS a ScrollView with a single item can be used to allow the user to zoom content.

How do I scroll to a specific element in react native?

If your list items are of equal height, you can use them to implement scrolling to a specific item by calling scrollTo({y:itemIndex * ROW_HEIGHT}) .


1 Answers

There is a workaround, wrap it in a setTimeout like so:

componentDidMount() {
  setTimeout(() => {
    this.refs.dateList.scrollToEnd();
  }, 50);
}
like image 182
Samuel G. P. Avatar answered Oct 02 '22 15:10

Samuel G. P.