[react-native]有没有办法知道flatList的渲染什么时候完成

cit*_*ice 5 android react-native react-native-flatlist

我有一个 flatList 视图,我希望它在数据更新时滚动到结束或滚动到索引(从服务器获取数据),我在 comoponentDidUpdate 中执行但它不起作用。现在当渲染完成时,listView 总是滚动到顶部而且我看不到最新加载的数据。所以有没有办法在渲染完成时捕获事件。

代码:

...
fetchData(){
    fetch(url)
    .then((res)=>{
        this.setData({data:[...this.state.data, res.data]})
    })
}
componentDidUpdate(){
    this.refs.listView.scrollToEnd({animated:true})
}
render(){
    return <FlatList ref='listView' data={this.state.data} onEndReached={()=>this.fetchData()}.../>
}
Run Code Online (Sandbox Code Playgroud)