Is it possible to keep a ScrollView scrolled to the bottom?

前端 未结 16 1315
误落风尘
误落风尘 2020-12-04 17:13

For a chat-like app, I want to keep a ScrollView component scrolled to the bottom, because newest messages appear under the older ones. Can we adjust the scroll

16条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-04 17:48

    For React Native 0.41 and later, you can do this with the built-in scrollToEnd method:

     {this.scrollView = ref}}
        onContentSizeChange={() => this.scrollView.scrollToEnd({animated: true})}>
    
    

提交回复
热议问题