Scroll to the bottom of the list after adding item react native list

FlatList chat conversation using the page list display assembly conversations, so that the bottom of the list to scroll, the following method may be achieved when adding a dialogue:
ref="flatlist"
onContentSizeChange = {() => {
     requestAnimationFrame(() => {
         this.refs.flatlist.scrollToEnd({
             animated: true
         });
     });
}}

Step: onContentSizeChange callback method when an array of changes in the implementation, requestAnimationFrame rendering animation frames, refs.doc.scrollToEnd for the built-in event, you can specify a list scroll to the bottom of the list

 

Guess you like

Origin www.cnblogs.com/neeter/p/12659468.html