I'm trying to scroll to the end of my FlatList when the state of messages changes. Currently I'm using this.refs.flatList.scrollToEnd(); after waiting a bit, which works OK. What I want to do is add an event listener to the messages state so that when the list is changed in any way it will scroll to the end of the list. I tried
componentDidMount(){
this.state.messages.addEventListener('change', this._handleNewMessage);
}
but it doesn't work. Does anyone know a way I can achieve this?